diff --git a/controllers/auth2.go b/controllers/auth2.go index 23e3e3d3a..eec2a8531 100644 --- a/controllers/auth2.go +++ b/controllers/auth2.go @@ -68,6 +68,9 @@ func (c *Auth2Controller) Login() { } else if params.AuthType == auth2.AuthTypeEmail { params.AuthIDType = auth2.UserIDEmail } + if params.AuthType == weixin.AuthTypeMini { + params.AuthSecret = GetComposedCode(&c.Controller, params.AuthSecret) + } retVal, err = auth2.Login(params.AuthType, params.AuthID, params.AuthIDType, params.AuthSecret) return retVal, "", err }) diff --git a/controllers/auth_controller.go b/controllers/auth_controller.go index 27cc404c4..2ebdff63c 100644 --- a/controllers/auth_controller.go +++ b/controllers/auth_controller.go @@ -76,7 +76,7 @@ func (c *AuthController) GetWeiXinUserInfo() { func (c *AuthController) Login() { c.callLogin(func(params *tAuthLoginParams) (retVal interface{}, errCode string, err error) { if params.Type == weixin.LoginTypeMiniProgram { - params.Secret = c.GetComposedCode((params.Secret)) + params.Secret = GetComposedCode(&c.Controller, params.Secret) } retVal, err = auth.Login(params.Id, params.Type, params.Secret) if err == auth.ErrUserNotExist { @@ -175,7 +175,7 @@ func (c *AuthController) BindMobile2() { // @router /MiniBindWeiXin [post] func (c *AuthController) MiniBindWeiXin() { c.callMiniBindWeiXin(func(params *tAuthMiniBindWeiXinParams) (retVal interface{}, errCode string, err error) { - err = weixin.AutherMini.BindWeiXin(params.Ctx, c.GetComposedCode(params.Code), params.Nickname) + err = weixin.AutherMini.BindWeiXin(params.Ctx, GetComposedCode(&c.Controller, params.Code), params.Nickname) if err == auth.ErrUserNotExist { return retVal, model.ErrCodeUserNotExist, err } @@ -192,7 +192,7 @@ func (c *AuthController) MiniBindWeiXin() { // @router /BindMiniProgram [post] func (c *AuthController) BindMiniProgram() { c.callBindMiniProgram(func(params *tAuthBindMiniProgramParams) (retVal interface{}, errCode string, err error) { - err = weixin.AutherMini.BindMiniProgram(params.Ctx, c.GetComposedCode(params.Code)) + err = weixin.AutherMini.BindMiniProgram(params.Ctx, GetComposedCode(&c.Controller, params.Code)) if err == auth.ErrUserNotExist { return retVal, model.ErrCodeUserNotExist, err } @@ -215,7 +215,7 @@ func (c *AuthController) MiniDecryptData() { }) } -func (c *AuthController) GetComposedCode(code string) (composedCode string) { +func GetComposedCode(c *beego.Controller, code string) (composedCode string) { composedCode = code referer := c.Ctx.Request.Referer() globals.SugarLogger.Debugf("GetComposedCode referer:%s", referer)