From e5d02223b71fd1212dbd1f3620ab7f16a3c69e94 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Tue, 27 Apr 2021 09:29:08 +0800 Subject: [PATCH] aa --- controllers/auth2.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/controllers/auth2.go b/controllers/auth2.go index 8c2470172..0e3eb3e61 100644 --- a/controllers/auth2.go +++ b/controllers/auth2.go @@ -207,7 +207,7 @@ func (c *Auth2Controller) WeixinMPOAuth2() { } } if params.Block != "" { - if moblie := params.Block[strings.LastIndex(params.Block,"=")+1:]; moblie != "" { + if moblie := params.Block[strings.LastIndex(params.Block, "=")+1:]; moblie != "" { if user, err := dao.GetUserByID(dao.GetDB(), "mobile", moblie); err == nil { if user != nil { authInfo.AuthBindInfo.UserID = user.UserID @@ -219,8 +219,8 @@ func (c *Auth2Controller) WeixinMPOAuth2() { } } } - if strings.Contains(params.Block,"?"){ - params.Block = params.Block[:strings.LastIndex(params.Block,"?" )] + if strings.Contains(params.Block, "?") { + params.Block = params.Block[:strings.LastIndex(params.Block, "?")] } redirectURL = fmt.Sprintf("%s?info=%s", params.Block, base64.StdEncoding.EncodeToString(utils.MustMarshal(callResult))) return retVal, model.ErrorCodeIgnore, err @@ -308,6 +308,22 @@ func (c *Auth2Controller) AddAuthBind() { }) } +// @Title 绑定认证方式 +// @Description 绑定认证方式 +// @Param token header string true "认证token" +// @Param authToken formData string true "之前通过login得到的新认证TOKEN" +// @Param mobile formData string true "之前通过getuserbyminiinfo得到的" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /AddAuthBindWithMobile [post] +func (c *Auth2Controller) AddAuthBindWithMobile() { + c.callAddAuthBindWithMobile(func(params *tAuth2AddAuthBindWithMobileParams) (retVal interface{}, errCode string, err error) { + newAuthInfo, err := auth2.GetTokenInfo(params.AuthToken) + err = auth2.AddAuthBindWithMobile(newAuthInfo, params.Mobile) + return retVal, "", err + }) +} + // @Title 删除认证方式 // @Description 删除认证方式 // @Param token header string true "认证token"