fix: allow refresh tokens in AuthMiddleware for refresh route and dispatch auth_error on 401s to force login redirect
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m23s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m23s
This commit is contained in:
parent
4c8e6b814c
commit
fbad71cbf2
3 changed files with 19 additions and 2 deletions
|
|
@ -59,8 +59,14 @@ func AuthMiddleware(jwtSecret string) fiber.Handler {
|
|||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "invalid token type for query parameter"})
|
||||
}
|
||||
} else {
|
||||
if tokenType != "access" {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "invalid token type for authorization header"})
|
||||
if c.Path() == "/api/auth/refresh" {
|
||||
if tokenType != "refresh" {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "invalid token type for refresh endpoint"})
|
||||
}
|
||||
} else {
|
||||
if tokenType != "access" {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "invalid token type for authorization header"})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue