UpdateUserByMiniInfo中更新头像或手机号

This commit is contained in:
gazebo
2019-11-12 09:29:19 +08:00
parent 977f08b13a
commit 5cf7e75aaf
2 changed files with 9 additions and 4 deletions

View File

@@ -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)
}
}
}