1
This commit is contained in:
@@ -2,9 +2,6 @@ package weixin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/weixinapi"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider"
|
||||
@@ -13,10 +10,11 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
AuthTypeWeixin = "wxqrcode" // 微信扫码
|
||||
AuthTypeMP = "weixinsns" // 公众号
|
||||
AuthTypeWXNative = "wxnative" // 微信APP
|
||||
AuthTypeWxApp = "weixinapp" //app微信登录()
|
||||
AuthTypeWeixin = "wxqrcode" // 微信扫码
|
||||
AuthTypeMP = "weixinsns" // 公众号
|
||||
AuthTypeWXNative = "wxnative" // 微信APP
|
||||
AuthTypeWxApp = "weixinapp" //app微信登录(商家版)
|
||||
AuthTypeWxAppCaishi = "weixinappcs" //app微信登录(用户版)
|
||||
)
|
||||
|
||||
type Auther struct {
|
||||
@@ -25,10 +23,11 @@ type Auther struct {
|
||||
}
|
||||
|
||||
var (
|
||||
AutherObjWX *Auther
|
||||
AutherObjMP *Auther
|
||||
AutherObjNative *Auther
|
||||
AutherObjApp *Auther
|
||||
AutherObjWX *Auther
|
||||
AutherObjMP *Auther
|
||||
AutherObjNative *Auther
|
||||
AutherObjApp *Auther
|
||||
AutherObjCaiShiApp *Auther
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -55,14 +54,16 @@ func init() {
|
||||
authType: AuthTypeWxApp,
|
||||
}
|
||||
auth2.RegisterAuther(AuthTypeWxApp, AutherObjApp)
|
||||
|
||||
AutherObjCaiShiApp = &Auther{
|
||||
authType: AuthTypeWxAppCaishi,
|
||||
}
|
||||
auth2.RegisterAuther(AuthTypeWxAppCaishi, AutherObjCaiShiApp)
|
||||
}
|
||||
|
||||
func (a *Auther) VerifySecret(id, secret string) (authBindEx *auth2.AuthBindEx, err error) {
|
||||
var openID, accessToken string
|
||||
appId, jsCode := SplitJsCode(secret)
|
||||
globals.SugarLogger.Debugf("=======appId := %s ,jscode := %s", appId, jsCode)
|
||||
globals.SugarLogger.Debugf("auther := %s", utils.Format4Output(a.authType, false))
|
||||
globals.SugarLogger.Debugf("auther := %s", utils.Format4Output(a.DefAuther, false))
|
||||
_, jsCode := SplitJsCode(secret)
|
||||
if a.authType != AuthTypeWXNative {
|
||||
state := id
|
||||
code := jsCode
|
||||
@@ -94,7 +95,7 @@ func (a *Auther) VerifySecret(id, secret string) (authBindEx *auth2.AuthBindEx,
|
||||
if err == nil {
|
||||
wxUserinfo, err2 := a.getAPI().SNSGetUserInfo(accessToken, openID)
|
||||
if err = err2; err == nil {
|
||||
if authBindEx, err = a.UnionFindAuthBind(a.authType, a.getAPI().GetAppID(), []string{AuthTypeWeixin, AuthTypeMP, AuthTypeMini, AuthTypeWXNative, AuthTypeWxApp}, wxUserinfo.OpenID, wxUserinfo.UnionID, wxUserinfo); err == nil {
|
||||
if authBindEx, err = a.UnionFindAuthBind(a.authType, a.getAPI().GetAppID(), []string{AuthTypeWeixin, AuthTypeMP, AuthTypeMini, AuthTypeWXNative, AuthTypeWxApp, AuthTypeWxAppCaishi}, wxUserinfo.OpenID, wxUserinfo.UnionID, wxUserinfo); err == nil {
|
||||
authBindEx.UserHint = &auth2.UserBasic{
|
||||
Name: wxUserinfo.NickName,
|
||||
Avatar: wxUserinfo.HeadImgURL,
|
||||
@@ -112,6 +113,9 @@ func (a *Auther) getAPI() *weixinapi.API {
|
||||
if a.authType == AuthTypeWxApp {
|
||||
return api.WeixinApp
|
||||
}
|
||||
if a.authType == AuthTypeWxAppCaishi {
|
||||
return api.WeixinApp2
|
||||
}
|
||||
return api.WeixinAPI
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user