fix: enhance authentication flow and session management in AuthHandler and middleware

This commit is contained in:
GitHub Actions
2026-02-13 23:43:17 +00:00
parent 661f1dff87
commit a88dd24de9
12 changed files with 710 additions and 321 deletions

View File

@@ -31,18 +31,12 @@ func OptionalAuth(authService *services.AuthService) gin.HandlerFunc {
return
}
claims, err := authService.ValidateToken(tokenString)
user, _, err := authService.AuthenticateToken(tokenString)
if err != nil {
c.Next()
return
}
user, err := authService.GetUserByID(claims.UserID)
if err != nil || !user.Enabled {
c.Next()
return
}
c.Set("userID", user.ID)
c.Set("role", user.Role)
c.Next()