This commit is contained in:
sjk
2026-01-06 19:36:42 +08:00
parent 15b579d64a
commit 19942144fb
261 changed files with 24034 additions and 5477 deletions

View File

@@ -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()