diff --git a/utils/auth/user.go b/utils/auth/user.go index 8869ebbd..67b6e5b4 100644 --- a/utils/auth/user.go +++ b/utils/auth/user.go @@ -25,6 +25,7 @@ const ( type UserInfo struct { UserId int64 `json:"user_id"` GuestId int64 `json:"guest_id"` + Exp int64 `json:"exp"` //截止有效时间 } // GetIdType 用户确认用户身份类型 @@ -77,6 +78,15 @@ type OAuthInfo struct { // 获取登录信息 func GetUserInfoFormMapClaims(claims jwt.MapClaims) (*UserInfo, error) { userinfo := &UserInfo{} + if exp, ok := claims["exp"]; ok { + expire, ok := exp.(float64) + if !ok { + err := errors.New(fmt.Sprint("parse exp form context err:", exp)) + logx.Error("parse exp form context err:", err) + return nil, err + } + userinfo.Exp = int64(expire) + } if userid, ok := claims["user_id"]; ok { uid, ok := userid.(float64) if !ok {