【修改认证说明】

This commit is contained in:
weizhihong 2023-09-07 14:36:23 +08:00
parent f3b864e59c
commit 7cdc1cebcc

View File

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