This commit is contained in:
aozhiwei 2024-11-04 15:37:53 +08:00
parent 25ee6dcf54
commit bcf307a92b
3 changed files with 29 additions and 12 deletions

View File

@ -3,6 +3,18 @@ package common
import (
)
type JwtUserInfo struct {
Id string `json:"id"`
Uid string `json:"uid"`
Gid string `json:"gid"`
OpenId string `json:"openid"`
Version int32 `json:"version"`
Plat int32 `json:"plat"`
PlatVip int32 `json:"platVip"`
Invited string `json:"invited"`
NickName string `json:"nickname"`
}
type App interface {
Run(func(), func())
}
@ -31,5 +43,5 @@ type Session interface {
type SessionMgr interface {
CreateGuestSession() Session
CreateFromJwt(string) Session
CreateJwtSession(*JwtUserInfo) Session
}

View File

@ -5,6 +5,7 @@ import (
"fmt"
"jccommon"
"main/mt"
"main/common"
"q5"
. "main/global"
@ -52,17 +53,7 @@ func internalMetaMaskJwtAuth(c *gin.Context, jwtToken string) {
jsonRspObj := &struct {
ErrCode interface{} `json:"errcode"`
ErrMsg string `json:"errmsg"`
Decoded struct {
Id string `json:"id"`
Uid string `json:"uid"`
Gid string `json:"gid"`
OpenId string `json:"openid"`
Version int32 `json:"version"`
Plat int32 `json:"plat"`
PlatVip int32 `json:"platVip"`
Invited string `json:"invited"`
NickName string `json:"nickname"`
} `json:"decoded"`
Decoded *common.JwtUserInfo `json:"decoded"`
}{}
rspObj := &struct {
ErrCode interface{} `json:"errcode"`
@ -102,6 +93,8 @@ func internalMetaMaskJwtAuth(c *gin.Context, jwtToken string) {
f5.GetSysLog().Info("not support this platform:%s", rsp.GetRawData())
return
}
s := GetSessionMgr().CreateJwtSession(jsonRspObj.Decoded)
c.Set("session", s)
c.Next()
})
}

View File

@ -1,5 +1,9 @@
package session
import (
"main/common"
)
type sessionMgr struct {
}
@ -11,3 +15,11 @@ func (this *sessionMgr) Init() {
func (this *sessionMgr) UnInit() {
}
func (this *sessionMgr) CreateGuestSession() common.Session {
return nil
}
func (this *sessionMgr) CreateJwtSession(userInfo *common.JwtUserInfo) common.Session {
return nil
}