diff --git a/server/pkg/middleware/auth.go b/server/pkg/middleware/auth.go index 9c4bb22808..5adeaf0567 100644 --- a/server/pkg/middleware/auth.go +++ b/server/pkg/middleware/auth.go @@ -1,7 +1,10 @@ package middleware import ( + "database/sql" + "errors" "fmt" + "github.com/sirupsen/logrus" "net/http" "strconv" @@ -48,6 +51,11 @@ func (m *AuthMiddleware) TokenAuthMiddleware(jwtClaimScope *jwt.ClaimScope) gin. userID, err = m.UserController.ValidateJWTToken(token, *jwtClaimScope) } else { userID, err = m.UserAuthRepo.GetUserIDWithToken(token, app) + if err != nil && !errors.Is(err, sql.ErrNoRows) { + logrus.Errorf("Failed to validate token: %s", err) + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "failed to validate token"}) + return + } } if err != nil { c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "invalid token"})