optimize jwt process logic to github.com/golang-jwt/jwt/v4 style

pull/188/head
Michael Li 2 years ago
parent 1ab3276eee
commit 09096507ef

@ -11,7 +11,7 @@ import (
type Claims struct { type Claims struct {
UID int64 `json:"uid"` UID int64 `json:"uid"`
Username string `json:"username"` Username string `json:"username"`
jwt.StandardClaims jwt.RegisteredClaims
} }
func GetJWTSecret() []byte { func GetJWTSecret() []byte {
@ -23,8 +23,8 @@ func GenerateToken(User *model.User) (string, error) {
claims := Claims{ claims := Claims{
UID: User.ID, UID: User.ID,
Username: User.Username, Username: User.Username,
StandardClaims: jwt.StandardClaims{ RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: expireTime.Unix(), ExpiresAt: jwt.NewNumericDate(expireTime),
Issuer: conf.JWTSetting.Issuer + ":" + User.Salt, Issuer: conf.JWTSetting.Issuer + ":" + User.Salt,
}, },
} }

Loading…
Cancel
Save