diff --git a/middleware/jwt.go b/middleware/jwt.go index f38075e..e97c311 100644 --- a/middleware/jwt.go +++ b/middleware/jwt.go @@ -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) { - 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 { // if v, ok := data.(*model.User); ok && v.Name == "sheng" {