电话咨询
This commit is contained in:
@@ -21,7 +21,7 @@ const (
|
||||
// TokenValidator Token 有效性校验接口
|
||||
// 由 AuthService 实现,中间件通过此接口检查 Token 是否在 Redis 中有效
|
||||
type TokenValidator interface {
|
||||
ValidateAccessToken(ctx context.Context, userID int64, clientType, token string) bool
|
||||
ValidateAccessToken(ctx context.Context, userID int64, clientType, token, username string) bool
|
||||
}
|
||||
|
||||
// JWTAuth JWT 认证中间件(有状态 JWT)
|
||||
@@ -70,7 +70,7 @@ func JWTAuth(jwtCfg *config.JWTConfig, validator TokenValidator) gin.HandlerFunc
|
||||
}
|
||||
|
||||
// 校验 Token 是否在 Redis 中有效(有状态 JWT 核心逻辑,按 clientType 隔离)
|
||||
if !validator.ValidateAccessToken(ctx, claims.UserID, clientType, tokenStr) {
|
||||
if !validator.ValidateAccessToken(ctx, claims.UserID, clientType, tokenStr, claims.Username) {
|
||||
logs.Warn(ctx, funcName, "Token 已失效(已登出或被覆盖)",
|
||||
zap.Int64("user_id", claims.UserID),
|
||||
zap.String("client_type", clientType),
|
||||
|
||||
Reference in New Issue
Block a user