提交 35eaa483 编写于 作者: Mr.奇淼('s avatar Mr.奇淼(

jwt异地登陆bug修复

上级 ebd91e4d
......@@ -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)
}
......
......@@ -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
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册