aa
This commit is contained in:
@@ -2,6 +2,7 @@ package weixin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
||||
@@ -56,13 +57,13 @@ func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, jsCode, encryptedData
|
||||
if jsCode != "" {
|
||||
sessionInfo, err := getWxApp(appID).SNSCode2Session(jsCode)
|
||||
if err == nil {
|
||||
// if authBindEx, err := a.UnionFindAuthBind(AuthTypeMini, getWxApp(appID).GetAppID(), []string{AuthTypeMini}, sessionInfo.OpenID, "", nil); err == nil {
|
||||
// if authBindEx.UserID != authInfo.GetID() {
|
||||
// return "", fmt.Errorf("jsCode与token不匹配")
|
||||
// }
|
||||
// } else {
|
||||
// return "", err
|
||||
// }
|
||||
if authBindEx, err := a.UnionFindAuthBind(AuthTypeMini, getWxApp(appID).GetAppID(), []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
|
||||
|
||||
@@ -6,8 +6,6 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
@@ -355,17 +353,25 @@ type UserInfoWithWeixin struct {
|
||||
// @Param data formData string true "加密数据"
|
||||
// @Param iv formData string true "iv"
|
||||
// @Param jsCode formData string false "小程序jsCode"
|
||||
// @Param authType formData string false "authType"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetUserByMiniInfo [post]
|
||||
func (c *Auth2Controller) GetUserByMiniInfo() {
|
||||
c.callGetUserByMiniInfo(func(params *tAuth2GetUserByMiniInfoParams) (retVal interface{}, errCode string, err error) {
|
||||
authInfo := &auth2.AuthInfo{}
|
||||
result := api.Cacher.Get(params.Token)
|
||||
utils.Map2StructByJson(result.(map[string]interface{}), &authInfo, false)
|
||||
// result := api.Cacher.Get(params.Token)
|
||||
// utils.Map2StructByJson(result.(map[string]interface{}), &authInfo, false)
|
||||
// authInfo, err := api.Cacher.Get(params.Token)
|
||||
jsCode := ""
|
||||
if params.AuthType == weixin.AuthTypeMini {
|
||||
jsCode = GetComposedCode(&c.Controller, params.JsCode)
|
||||
}
|
||||
if params.AuthType == weixin.AuthTypeWxApp {
|
||||
jsCode = GetComposedCode2(&c.Controller, params.JsCode)
|
||||
}
|
||||
if err == nil {
|
||||
decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, GetComposedCode(&c.Controller, params.JsCode), params.Data, params.Iv)
|
||||
decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, jsCode, params.Data, params.Iv)
|
||||
if err = err2; err == nil {
|
||||
var userInfo *weixinapi.MiniUserInfo
|
||||
if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user