feat: add tenant commands
This commit is contained in:
@@ -11,6 +11,10 @@ import (
|
||||
)
|
||||
|
||||
func (f *Middlewares) WeChatAuthUserInfo(c fiber.Ctx) error {
|
||||
if len(c.GetReqHeaders()["Authorization"]) != 0 {
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
state := c.Query("state")
|
||||
code := c.Query("code")
|
||||
|
||||
@@ -40,13 +44,16 @@ func (f *Middlewares) WeChatAuthUserInfo(c fiber.Ctx) error {
|
||||
}
|
||||
|
||||
var oauthInfo pg.UserOAuth
|
||||
copier.Copy(&oauthInfo, token)
|
||||
if err := copier.Copy(&oauthInfo, token); err != nil {
|
||||
return errors.Wrap(err, "failed to copy oauth info")
|
||||
}
|
||||
|
||||
user, err := f.userSvc.GetOrNew(c.Context(), tenantId, token.Openid, oauthInfo)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get user")
|
||||
}
|
||||
|
||||
claim := f.jwt.CreateClaims(jwt.BaseClaims{UID: uint64(user.ID)})
|
||||
claim := f.jwt.CreateClaims(jwt.BaseClaims{OpenID: user.OpenID})
|
||||
claim.ID = user.OpenID
|
||||
jwtToken, err := f.jwt.CreateToken(claim)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user