feat: use JWT Subject
This commit is contained in:
parent
713c0adc14
commit
714ef57027
3 changed files with 15 additions and 16 deletions
|
|
@ -70,7 +70,7 @@ func JWTAuthMiddleware(secret string) gin.HandlerFunc {
|
|||
return
|
||||
}
|
||||
|
||||
if claims.UserID == "" {
|
||||
if claims.Subject == "" {
|
||||
abortWithJSON(c, http.StatusUnauthorized, "user_id claim missing or invalid")
|
||||
return
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ func JWTAuthMiddleware(secret string) gin.HandlerFunc {
|
|||
}
|
||||
|
||||
// 5. Сохраняем в контексте
|
||||
c.Set("user_id", claims.UserID)
|
||||
c.Set("user_id", claims.Subject)
|
||||
|
||||
// 6. Для oapi-codegen — кладём gin.Context в request context
|
||||
GinContextToContext(c)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue