新增修改用户手机号为微信绑定的手机号,user2/UpdateUserByMiniInfo

This commit is contained in:
gazebo
2019-11-11 16:50:21 +08:00
parent 281e2b436a
commit e763aac526
4 changed files with 63 additions and 43 deletions

View File

@@ -2,6 +2,7 @@ package weixin
import (
"errors"
"fmt"
"strings"
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
@@ -44,12 +45,29 @@ func (a *MiniAuther) VerifySecret(dummy, jsCode string) (authBindEx *auth2.AuthB
}
// 特殊接口
func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, encryptedData, iv string) (decryptedDataBase64 string, err error) {
globals.SugarLogger.Debugf("weixin mini DecryptData encryptedData:%s, iv:%s", encryptedData, iv)
if authInfo.AuthBindInfo.Type != AuthTypeMini {
return "", ErrAuthTypeShouldBeMini
func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData, iv string) (decryptedDataBase64 string, err error) {
globals.SugarLogger.Debugf("weixin mini DecryptData jsCode:%s, encryptedData:%s, iv:%s", jsCode, encryptedData, iv)
var sessionKey string
if jsCode != "" {
sessionInfo, err := ProxySNSCode2Session(jsCode)
if err == nil {
if authBindEx, err := a.UnionFindAuthBind(AuthTypeMini, []string{AuthTypeMini}, sessionInfo.OpenID, "", nil); err == nil {
if authBindEx.UserID != authInfo.GetID() {
return "", fmt.Errorf("jsCode与token不匹配")
}
} else {
return "", err
}
sessionKey = sessionInfo.SessionKey
} else {
return "", err
}
} else {
if authInfo.AuthBindInfo.Type != AuthTypeMini {
return "", ErrAuthTypeShouldBeMini
}
sessionKey = authInfo.AuthBindInfo.UserData.(string)
}
sessionKey := authInfo.AuthBindInfo.UserData.(string)
decryptedData, err := ProxySNSDecodeMiniProgramData(encryptedData, sessionKey, iv)
if err != nil {
return "", err