🐛 Fix auth middlewares

This commit is contained in:
2024-10-27 00:20:44 +08:00
parent 999cc2bcd8
commit 3d487fa48b
4 changed files with 19 additions and 8 deletions

View File

@ -26,8 +26,11 @@ func ContextMiddleware(c *fiber.Ctx) error {
func ValidatorMiddleware(c *fiber.Ctx) error {
if c.Locals("nex_principal") == nil {
err := c.Locals("nex_auth_error").(error)
return fiber.NewError(fiber.StatusUnauthorized, err.Error())
if err, ok := c.Locals("nex_auth_error").(error); ok {
return fiber.NewError(fiber.StatusUnauthorized, err.Error())
} else {
return fiber.NewError(fiber.StatusUnauthorized, "unauthorized")
}
}
return c.Next()