- auth2也支持多小程序登录

This commit is contained in:
gazebo
2019-08-13 11:49:42 +08:00
parent cd84cbdfd2
commit d4270bf8c3
2 changed files with 7 additions and 4 deletions

View File

@@ -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
})

View File

@@ -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)