- because weixinsns removed.
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"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/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/mobile"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/mobile"
|
||||||
@@ -34,7 +34,7 @@ type Auther struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UserInfoExt struct {
|
type UserInfoExt struct {
|
||||||
weixinsnsapi.UserInfo
|
weixinapi.SNSUserInfo
|
||||||
TempPassword string `json:"tempPassword"` // 一段时间有效的登录密码
|
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)
|
globals.SugarLogger.Debugf("GetUserInfo code:%s", code)
|
||||||
|
|
||||||
if state == "" {
|
if state == "" {
|
||||||
wxapi := weixinsnsapi.New(api.WeixinAPI.GetAppID(), api.WeixinAPI.GetSecret())
|
token, err2 := api.WeixinAPI.SNSGetToken(code)
|
||||||
token, err2 := wxapi.RefreshToken(code)
|
|
||||||
if err = err2; err == nil {
|
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 {
|
if err = err2; err == nil {
|
||||||
pwd := utils.GetUUID()
|
pwd := utils.GetUUID()
|
||||||
globals.SugarLogger.Debugf("GetUserInfo code:%s, pwd:%s", code, pwd)
|
globals.SugarLogger.Debugf("GetUserInfo code:%s, pwd:%s", code, pwd)
|
||||||
api.Cacher.Set(wxUserinfo.OpenID, pwd, DefTempPasswordDuration)
|
api.Cacher.Set(wxUserinfo.OpenID, pwd, DefTempPasswordDuration)
|
||||||
return &UserInfoExt{
|
return &UserInfoExt{
|
||||||
UserInfo: *wxUserinfo,
|
SNSUserInfo: *wxUserinfo,
|
||||||
TempPassword: pwd,
|
TempPassword: pwd,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user