This commit is contained in:
aozhiwei 2024-08-06 17:47:46 +08:00
parent 4b776fc90b
commit cac07eb218
3 changed files with 9 additions and 1 deletions

View File

@ -24,6 +24,7 @@ func (this *UserApi) Info(c *gin.Context) {
Gold string `json:"gold"`
Diamond string `json:"diamond"`
}{}
rspObj.Email = c.MustGet("email").(string)
var contributionPoint float64
var gold float64
var diamond float64
@ -41,6 +42,7 @@ func (this *UserApi) Info(c *gin.Context) {
return
}
if ds.Next() {
rspObj.NickName = ds.GetByName("name")
gold = q5.ToFloat64(ds.GetByName("gold"))
diamond = q5.ToFloat64(ds.GetByName("diamond"))
}

View File

@ -30,6 +30,7 @@ func internalJwtAuth(c *gin.Context, maybe bool) {
if maybe {
c.Set("open_id", "")
c.Set("account_address", "")
c.Set("email", "")
c.Next()
return
}
@ -101,6 +102,7 @@ func internalImmutJwtAuth(c *gin.Context, jwtToken string) {
openId := fmt.Sprintf("%d_2006_%s", jccommon.IMTBL_CHANNEL, jsonRspObj.Decoded.Sub)
c.Set("open_id", openId)
c.Set("account_address", jsonRspObj.Decoded.Passport.ZkevmEthAddress)
c.Set("email", jsonRspObj.Decoded.Email)
c.Next()
})
}
@ -167,6 +169,7 @@ func internalMetaMaskJwtAuth(c *gin.Context, jwtToken string) {
strings.ToLower(jsonRspObj.Decoded.OpenId))
c.Set("open_id", openId)
c.Set("account_address", strings.ToLower(jsonRspObj.Decoded.OpenId))
c.Set("email", "")
c.Next()
})
}

View File

@ -2,6 +2,7 @@ package user
import (
"f5"
"main/middleware"
"main/api/v1"
)
@ -9,5 +10,7 @@ type UserRouter struct{}
func (this *UserRouter) InitRouter() {
api := v1.ApiGroupApp.UserApiGroup
f5.GetApp().GetGinEngine().GET("/api/user/:account_address", api.UserApi.Info)
f5.GetApp().GetGinEngine().GET("/api/user/:account_address",
middleware.MaybeJwtAuth,
api.UserApi.Info)
}