修复 jwt secret 类型错误问题
This commit is contained in:
parent
fcdda09503
commit
cccfc05ea7
4
jwt.go
4
jwt.go
@ -38,7 +38,7 @@ func (j *ownJwt) Generate(signMethod jwt.SigningMethod, secret string, claims jw
|
|||||||
} else {
|
} else {
|
||||||
token = jwt.NewWithClaims(signMethod, claims)
|
token = jwt.NewWithClaims(signMethod, claims)
|
||||||
}
|
}
|
||||||
return token.SignedString(secret)
|
return token.SignedString([]byte(secret))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate 验证token
|
// Validate 验证token
|
||||||
@ -53,7 +53,7 @@ func (j *ownJwt) Validate(inputToken string, secret string) (jwt.Claims, error)
|
|||||||
)
|
)
|
||||||
|
|
||||||
if token, err = jwt.Parse(inputToken, func(tokenInfo *jwt.Token) (interface{}, error) {
|
if token, err = jwt.Parse(inputToken, func(tokenInfo *jwt.Token) (interface{}, error) {
|
||||||
return secret, nil
|
return []byte(secret), nil
|
||||||
}); nil != err {
|
}); nil != err {
|
||||||
return nil, errors.New("token parse fail : " + err.Error())
|
return nil, errors.New("token parse fail : " + err.Error())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user