Merge branch 'develop' into feature/websocket

This commit is contained in:
laodaming 2023-10-12 14:31:04 +08:00
commit e2b174a58f

View File

@ -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 {