- because weixinsns removed.

This commit is contained in:
gazebo
2018-12-27 16:15:14 +08:00
parent 742fc359cd
commit b1a7cfdaa8

View File

@@ -5,7 +5,7 @@ import (
"fmt"
"time"
"git.rosy.net.cn/baseapi/platformapi/weixinsnsapi"
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/mobile"
@@ -34,7 +34,7 @@ type Auther struct {
}
type UserInfoExt struct {
weixinsnsapi.UserInfo
weixinapi.SNSUserInfo
TempPassword string `json:"tempPassword"` // 一段时间有效的登录密码
}
@@ -47,16 +47,15 @@ func GetUserInfo(code string, state string) (token *UserInfoExt, err error) {
globals.SugarLogger.Debugf("GetUserInfo code:%s", code)
if state == "" {
wxapi := weixinsnsapi.New(api.WeixinAPI.GetAppID(), api.WeixinAPI.GetSecret())
token, err2 := wxapi.RefreshToken(code)
token, err2 := api.WeixinAPI.SNSGetToken(code)
if err = err2; err == nil {
wxUserinfo, err2 := wxapi.GetUserInfo(token.OpenID)
wxUserinfo, err2 := api.WeixinAPI.SNSGetUserInfo(token.AccessToken, token.OpenID)
if err = err2; err == nil {
pwd := utils.GetUUID()
globals.SugarLogger.Debugf("GetUserInfo code:%s, pwd:%s", code, pwd)
api.Cacher.Set(wxUserinfo.OpenID, pwd, DefTempPasswordDuration)
return &UserInfoExt{
UserInfo: *wxUserinfo,
SNSUserInfo: *wxUserinfo,
TempPassword: pwd,
}, nil
}