🐛 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

@ -15,7 +15,7 @@ func ContextMiddleware(tkReader *InternalTokenReader) fiber.Handler {
token := c.Get(fiber.HeaderAuthorization)
token = strings.TrimSpace(strings.Replace(token, "Bearer ", "", 1))
if len(token) == 0 {
return fiber.NewError(fiber.StatusUnauthorized, "no authorization token is provided")
return c.Next()
}
data, err := tkReader.ReadUserInfoJwt(token)
@ -28,7 +28,7 @@ func ContextMiddleware(tkReader *InternalTokenReader) fiber.Handler {
}
}
// ValidatorMiddleware will ensure request is authenticated
// ValidatorMiddleware will ensure the request is authenticated
// Make sure call this middleware after ContextMiddleware
func ValidatorMiddleware(c *fiber.Ctx) error {
if c.Locals("nex_user") == nil {