|
|
@ -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,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|