update: new logging functions

This commit is contained in:
ngn
2024-08-13 22:40:44 +03:00
parent 4641faefc2
commit 561f9a2340
13 changed files with 76 additions and 478 deletions

View File

@ -1,9 +1,8 @@
package routes
import (
"log"
"git.matterlinux.xyz/matter/security/lib"
"git.matterlinux.xyz/matter/security/log"
"github.com/gofiber/fiber/v2"
)
@ -16,7 +15,7 @@ func MiddleAuth(c *fiber.Ctx) error {
users, err := lib.LoadUsers()
if err != nil {
log.Printf("Failed to load users: %s", err.Error())
log.Error("Failed to load users: %s", err.Error())
return lib.RenderError(c, 500)
}
@ -34,21 +33,21 @@ func MiddleAuth(c *fiber.Ctx) error {
return c.Redirect("/login")
}
func GETManage(c *fiber.Ctx) error {
func GET_Manage(c *fiber.Ctx) error {
return c.Render("manage", fiber.Map{})
}
func GETLogout(c *fiber.Ctx) error {
func GET_Logout(c *fiber.Ctx) error {
user, err := lib.GetUser(c)
if err != nil {
log.Printf("Failed to load user: %s", err.Error())
log.Error("Failed to load user: %s", err.Error())
return lib.RenderError(c, 500)
}
user.Cookie = "notset"
err = lib.UpdateUser(user)
if err != nil {
log.Printf("Failed to save users: %s", err.Error())
log.Error("Failed to save users: %s", err.Error())
return lib.RenderError(c, 500)
}