aa
This commit is contained in:
@@ -35,6 +35,20 @@ func GetComposedCode(c *web.Controller, code string) (composedCode string) {
|
||||
return composedCode
|
||||
}
|
||||
|
||||
func GetComposedCode2(c *web.Controller, code string) (composedCode string) {
|
||||
composedCode = code
|
||||
referer := c.Ctx.Request.UserAgent()
|
||||
globals.SugarLogger.Debugf("GetComposedCode referer:%s", referer)
|
||||
index := strings.Index(referer, "//")
|
||||
if index > 0 {
|
||||
list := strings.Split(referer[index+2:], "/")
|
||||
if len(list) >= 2 {
|
||||
composedCode = weixin.ComposeJsCode(list[1], code)
|
||||
}
|
||||
}
|
||||
return composedCode
|
||||
}
|
||||
|
||||
type Auth2Controller struct {
|
||||
web.Controller
|
||||
}
|
||||
@@ -92,9 +106,12 @@ func (c *Auth2Controller) Login() {
|
||||
} else if params.AuthType == auth2.AuthTypeEmail {
|
||||
params.AuthIDType = auth2.UserIDEmail
|
||||
}
|
||||
if params.AuthType == weixin.AuthTypeMini || params.AuthType == weixin.AuthTypeWxApp {
|
||||
if params.AuthType == weixin.AuthTypeMini {
|
||||
params.AuthSecret = GetComposedCode(&c.Controller, params.AuthSecret)
|
||||
}
|
||||
if params.AuthType == weixin.AuthTypeWxApp {
|
||||
params.AuthSecret = GetComposedCode2(&c.Controller, params.AuthSecret)
|
||||
}
|
||||
ctx := auth2.NewContext(c.Ctx.ResponseWriter, c.Ctx.Request)
|
||||
authInfo, err := auth2.Login(ctx, params.AuthType, params.AuthID, params.AuthIDType, params.AuthSecret)
|
||||
// TODO 兼容没有取到authid2的错误
|
||||
|
||||
Reference in New Issue
Block a user