fix
This commit is contained in:
parent
df1b599e51
commit
f5744c8d09
|
@ -25,6 +25,7 @@ const (
|
||||||
type UserInfo struct {
|
type UserInfo struct {
|
||||||
UserId int64 `json:"user_id"`
|
UserId int64 `json:"user_id"`
|
||||||
GuestId int64 `json:"guest_id"`
|
GuestId int64 `json:"guest_id"`
|
||||||
|
Exp int64 `json:"exp"` //截止有效时间
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIdType 用户确认用户身份类型
|
// GetIdType 用户确认用户身份类型
|
||||||
|
@ -77,6 +78,15 @@ type OAuthInfo struct {
|
||||||
// 获取登录信息
|
// 获取登录信息
|
||||||
func GetUserInfoFormMapClaims(claims jwt.MapClaims) (*UserInfo, error) {
|
func GetUserInfoFormMapClaims(claims jwt.MapClaims) (*UserInfo, error) {
|
||||||
userinfo := &UserInfo{}
|
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 {
|
if userid, ok := claims["user_id"]; ok {
|
||||||
uid, ok := userid.(float64)
|
uid, ok := userid.(float64)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user