Skip to content

Commit

Permalink
Update JWT middleware calls
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirAgassi committed Dec 17, 2024
1 parent a3aa32f commit acce0f7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/internal/middleware/jwt.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package middleware

import (
"fmt"
"net/http"
"strings"

Expand Down Expand Up @@ -29,7 +28,7 @@ func Auth(config AuthConfig, dbPool *pgxpool.Pool) echo.MiddlewareFunc {
}

// get user salt from db using claims
claims, err := jwt.ParseToken(parts[1])
claims, err := jwt.ParseUnverifiedClaims(parts[1])
if err != nil {
return echo.NewHTTPError(http.StatusUnauthorized, "invalid token")
}
Expand Down Expand Up @@ -65,7 +64,8 @@ func Auth(config AuthConfig, dbPool *pgxpool.Pool) echo.MiddlewareFunc {
}

// verify token with user's salt
if err := jwt.VerifyTokenWithSalt(parts[1], salt); err != nil {
claims, err = jwt.VerifyTokenWithSalt(parts[1], salt)
if err != nil {
return echo.NewHTTPError(http.StatusUnauthorized, "invalid token")
}

Expand Down

0 comments on commit acce0f7

Please sign in to comment.