fix: documents api
This commit is contained in:
@@ -11,12 +11,12 @@ var userClaimsKey = struct{}{}
|
||||
func JWTRequired(c *fiber.Ctx) error {
|
||||
jwt := c.Get("Authorization")
|
||||
if jwt == "" {
|
||||
return c.Status(401).JSON(fiber.Map{"msg": "Unauthorized"})
|
||||
return fiber.ErrUnauthorized
|
||||
}
|
||||
claims, err := casdoorsdk.ParseJwtToken(jwt)
|
||||
if err != nil {
|
||||
log.Ctx(c.UserContext()).Error().Err(err).Msg("Unauthorized user")
|
||||
return c.Status(401).JSON(fiber.Map{"msg": "Unauthorized"})
|
||||
return fiber.ErrUnauthorized
|
||||
}
|
||||
c.Locals(userClaimsKey, claims)
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user