This commit is contained in:
苏尹岚
2020-11-20 11:30:40 +08:00
parent 969f597557
commit b2ac231af3
2 changed files with 8 additions and 9 deletions

View File

@@ -2,7 +2,6 @@ package weixin
import ( import (
"errors" "errors"
"fmt"
"strings" "strings"
"git.rosy.net.cn/baseapi/platformapi/weixinapi" "git.rosy.net.cn/baseapi/platformapi/weixinapi"
@@ -57,13 +56,13 @@ func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData
if jsCode != "" { if jsCode != "" {
sessionInfo, err := getWxApp(appID).SNSCode2Session(jsCode) sessionInfo, err := getWxApp(appID).SNSCode2Session(jsCode)
if err == nil { if err == nil {
if authBindEx, err := a.UnionFindAuthBind(AuthTypeMini, getWxApp(appID).GetAppID(), []string{AuthTypeMini}, sessionInfo.OpenID, "", nil); err == nil { // if authBindEx, err := a.UnionFindAuthBind(AuthTypeMini, getWxApp(appID).GetAppID(), []string{AuthTypeMini}, sessionInfo.OpenID, "", nil); err == nil {
if authBindEx.UserID != authInfo.GetID() { // if authBindEx.UserID != authInfo.GetID() {
return "", fmt.Errorf("jsCode与token不匹配") // return "", fmt.Errorf("jsCode与token不匹配")
} // }
} else { // } else {
return "", err // return "", err
} // }
sessionKey = sessionInfo.SessionKey sessionKey = sessionInfo.SessionKey
} else { } else {
return "", err return "", err

View File

@@ -302,7 +302,7 @@ type UserInfoWithWeixin struct {
// @router /GetUserByMiniInfo [get] // @router /GetUserByMiniInfo [get]
func (c *User2Controller) GetUserByMiniInfo() { func (c *User2Controller) GetUserByMiniInfo() {
c.callGetUserByMiniInfo(func(params *tUser2GetUserByMiniInfoParams) (retVal interface{}, errCode string, err error) { c.callGetUserByMiniInfo(func(params *tUser2GetUserByMiniInfoParams) (retVal interface{}, errCode string, err error) {
authInfo, err := params.Ctx.GetV2AuthInfo() authInfo := &auth2.AuthInfo{}
if err == nil { if err == nil {
decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, GetComposedCode(&c.Controller, params.JsCode), params.Data, params.Iv) decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, GetComposedCode(&c.Controller, params.JsCode), params.Data, params.Iv)
if err = err2; err == nil { if err = err2; err == nil {