commit
This commit is contained in:
@@ -3,6 +3,7 @@ package middleware
|
||||
import (
|
||||
"ai_xhs/common"
|
||||
"ai_xhs/utils"
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -35,6 +36,14 @@ func AuthMiddleware() gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
// 新增:验证token是否在Redis中存在(校验是否被禁用)
|
||||
ctx := context.Background()
|
||||
if err := utils.ValidateTokenInRedis(ctx, claims.EmployeeID, parts[1]); err != nil {
|
||||
common.Error(c, common.CodeUnauthorized, err.Error())
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
// 将员工ID存入上下文
|
||||
c.Set("employee_id", claims.EmployeeID)
|
||||
c.Next()
|
||||
|
||||
Reference in New Issue
Block a user