Skip to content

Commit

Permalink
♻️ refactor: Updated JWT middleware to align with changed payload key…
Browse files Browse the repository at this point in the history
… from 'user_id' to 'id

This commit implements necessary modifications to the JWT authentication middleware to accommodate the recent change in the JWT payload structure, where the key has been updated from 'user_id' to 'id'. The adjustment ensures that the middleware accurately verifies token values against the updated key, maintaining the integrity and functionality of the authentication process. Key updates include revising the token parsing logic within the middleware to recognize the 'id' key, updating related unit tests to reflect the new payload structure, and ensuring backward compatibility where necessary. This change underscores our ongoing efforts to enhance code consistency and improve security measures across the application.

Related issue: #210
  • Loading branch information
Regulus0811 committed Apr 22, 2024
1 parent a04c906 commit 2769642
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion middlewares/authentication_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TokenAuthMiddleware(jwtService services.JWTService) gin.HandlerFunc {
}

claims := token.Claims.(jwt.MapClaims)
userID := uint(claims["user_id"].(float64))
userID := uint(claims["id"].(float64))
c.Set("userID", userID)

c.Next()
Expand Down

0 comments on commit 2769642

Please sign in to comment.