修复 jwt secret 类型错误问题

This commit is contained in:
白茶清欢 2023-02-12 00:00:50 +08:00
parent fcdda09503
commit cccfc05ea7

4
jwt.go
View File

@ -38,7 +38,7 @@ func (j *ownJwt) Generate(signMethod jwt.SigningMethod, secret string, claims jw
} else {
token = jwt.NewWithClaims(signMethod, claims)
}
return token.SignedString(secret)
return token.SignedString([]byte(secret))
}
// 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) {
return secret, nil
return []byte(secret), nil
}); nil != err {
return nil, errors.New("token parse fail : " + err.Error())
}