diff --git a/server/middleware/jwt.go b/server/middleware/jwt.go index cd671d44..cfc9d0bb 100644 --- a/server/middleware/jwt.go +++ b/server/middleware/jwt.go @@ -26,7 +26,7 @@ func JWTAuth() gin.HandlerFunc { c.Abort() return } - if service.IsBlacklist(token,modelToken) { + if service.IsBlacklist(token, &modelToken) { response.Result(response.ERROR, gin.H{ "reload": true, }, "您的帐户异地登陆或令牌失效", c) @@ -66,8 +66,6 @@ var ( TokenInvalid error = errors.New("Couldn't handle this token:") ) - - func NewJWT() *JWT { return &JWT{ []byte(global.GVA_CONFIG.JWT.SigningKey), @@ -75,7 +73,7 @@ func NewJWT() *JWT { } //创建一个token -func (j *JWT) CreateToken(claims request. CustomClaims) (string, error) { +func (j *JWT) CreateToken(claims request.CustomClaims) (string, error) { token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) return token.SignedString(j.SigningKey) } diff --git a/server/service/jwt_black_list.go b/server/service/jwt_black_list.go index 888d5b61..eab1b55f 100644 --- a/server/service/jwt_black_list.go +++ b/server/service/jwt_black_list.go @@ -19,7 +19,7 @@ func JsonInBlacklist(j *model.JwtBlacklist) (err error) { // @auth (2020/04/05 20:22 ) // @param newPassword string // @return err error -func IsBlacklist(Jwt string, j model.JwtBlacklist) bool { +func IsBlacklist(Jwt string, j *model.JwtBlacklist) bool { isNotFound := global.GVA_DB.Where("jwt = ?", Jwt).First(j).RecordNotFound() return !isNotFound } @@ -43,4 +43,3 @@ func SetRedisJWT(j model.JwtBlacklist, userName string) (err error) { err = global.GVA_REDIS.Set(userName, j.Jwt, 1000*1000*1000*60*60*24*7).Err() return err } -