diff --git a/business/auth2/authprovider/weixin/weixin_mini.go b/business/auth2/authprovider/weixin/weixin_mini.go index cd6e4510e..6e079b7ee 100644 --- a/business/auth2/authprovider/weixin/weixin_mini.go +++ b/business/auth2/authprovider/weixin/weixin_mini.go @@ -68,7 +68,6 @@ func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData } sessionKey = authInfo.AuthBindInfo.UserData.(string) } - globals.SugarLogger.Debugf("weixin mini DecryptData2 jsCode:%s, encryptedData:%s, iv:%s, sessionKey:%s", jsCode, encryptedData, iv, sessionKey) decryptedData, err := ProxySNSDecodeMiniProgramData(encryptedData, sessionKey, iv) if err != nil { return "", err @@ -94,6 +93,7 @@ func ProxySNSCode2Session(jsCode string) (sessionInfo *weixinapi.SessionInfo, er } func ProxySNSDecodeMiniProgramData(encryptedData, sessionKey, iv string) (decryptedData []byte, err error) { + globals.SugarLogger.Debugf("ProxySNSDecodeMiniProgramData, encryptedData:%s, sessionKey:%s, iv:%s", encryptedData, sessionKey, iv) decryptedData, err = api.WeixinMiniAPI.SNSDecodeMiniProgramData(encryptedData, sessionKey, iv) return decryptedData, err } diff --git a/controllers/cms_user2.go b/controllers/cms_user2.go index e29f7ebef..71cd2d452 100644 --- a/controllers/cms_user2.go +++ b/controllers/cms_user2.go @@ -393,12 +393,17 @@ func (c *Auth2Controller) UpdateUserByMiniInfo() { if err == nil { decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, GetComposedCode(&c.Controller, params.JsCode), params.Data, params.Iv) if err = err2; err == nil { - retVal = decryptedDataBase64 var userInfo *weixinapi.MiniUserInfo if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil { + retVal = userInfo if user := params.Ctx.GetFullUser(); user != nil { - user.Avatar = userInfo.AvatarURL - dao.UpdateEntity(dao.GetDB(), user, "Avatar") + if userInfo.AvatarURL != "" { + user.Avatar = userInfo.AvatarURL + } + if userInfo.PurePhoneNumber != "" { + user.Mobile = utils.String2Pointer(userInfo.PurePhoneNumber) + } + dao.UpdateEntity(dao.GetDB(), user) } } }