【修改认证说明】

This commit is contained in:
weizhihong 2023-09-07 14:36:23 +08:00
parent f3b864e59c
commit 7cdc1cebcc
1 changed files with 6 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package middleware
import (
"log"
"strconv"
"strings"
"time"
jwt "github.com/appleboy/gin-jwt/v2"
@ -56,7 +57,11 @@ func InitGinJwtMiddleware() (authMiddleware *jwt.GinJWTMiddleware) {
return user, nil
},
Unauthorized: func(c *gin.Context, code int, message string) {
if strings.Contains(message, "token") {
c.JSON(code, gin.H{"code": code, "title": "token过期", "message": message})
} else {
c.JSON(code, gin.H{"code": code, "title": "登录认证失败", "message": message})
}
},
// Authorizator: func(data interface{}, c *gin.Context) bool {
// if v, ok := data.(*model.User); ok && v.Name == "sheng" {