diff --git a/server/wheelserver/common/types.go b/server/wheelserver/common/types.go index ec0c7210..d502e6f7 100644 --- a/server/wheelserver/common/types.go +++ b/server/wheelserver/common/types.go @@ -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 } diff --git a/server/wheelserver/middleware/jwtauth.go b/server/wheelserver/middleware/jwtauth.go index 7733f718..b1f54d47 100644 --- a/server/wheelserver/middleware/jwtauth.go +++ b/server/wheelserver/middleware/jwtauth.go @@ -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() }) } diff --git a/server/wheelserver/session/sessionmgr.go b/server/wheelserver/session/sessionmgr.go index da34c12a..db23fdea 100644 --- a/server/wheelserver/session/sessionmgr.go +++ b/server/wheelserver/session/sessionmgr.go @@ -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 +}