修改MiniDecryptData中的bug
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package weixin
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
@@ -55,7 +54,7 @@ func (a *MiniAuther) DecryptData(authInfo *auth2.AuthInfo, encryptedData, iv str
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return base64.StdEncoding.EncodeToString(decryptedData), nil
|
||||
return string(decryptedData), nil
|
||||
}
|
||||
|
||||
func (a *MiniAuther) GetUserType() (userType int8) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/dingding"
|
||||
@@ -13,9 +14,9 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/password"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/astaxie/beego"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
)
|
||||
|
||||
func GetComposedCode(c *beego.Controller, code string) (composedCode string) {
|
||||
@@ -309,10 +310,14 @@ func (c *Auth2Controller) MiniDecryptData() {
|
||||
c.callMiniDecryptData(func(params *tAuth2MiniDecryptDataParams) (retVal interface{}, errCode string, err error) {
|
||||
authInfo, err := params.Ctx.GetV2AuthInfo()
|
||||
if err == nil {
|
||||
if retVal, err = weixin.AutherObjMini.DecryptData(authInfo, params.Data, params.Iv); err == nil {
|
||||
if user:= params.Ctx.GetFullUser(); user != nil {
|
||||
user.Avatar = "avatar"
|
||||
dao.UpdateEntity(dao.GetDB(), user, "Avatar")
|
||||
decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, params.Data, params.Iv)
|
||||
if err = err2; err == nil {
|
||||
var userInfo *weixinapi.MiniUserInfo
|
||||
if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil {
|
||||
if user := params.Ctx.GetFullUser(); user != nil {
|
||||
user.Avatar = userInfo.AvatarURL
|
||||
dao.UpdateEntity(dao.GetDB(), user, "Avatar")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user