aa
This commit is contained in:
@@ -340,6 +340,18 @@ func AddAuthBind(user IUser, newAuthInfo *AuthInfo) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AddAuthBindWithMobile(authInfo *AuthInfo, mobile string) (err error) {
|
||||||
|
if handler := authers[authInfo.AuthBindInfo.Type]; handler != nil {
|
||||||
|
user, _ := dao.GetUserByID(dao.GetDB(), "mobile", mobile)
|
||||||
|
authInfo.AuthBindInfo.UserID = user.UserID
|
||||||
|
//handler.UnbindAuth(user.GetID(), newAuthInfo.GetAuthType(), newAuthInfo.GetAuthTypeID(), user.GetName())
|
||||||
|
err = handler.AddAuthBind(authInfo.AuthBindInfo, user.GetName())
|
||||||
|
} else {
|
||||||
|
err = ErrIllegalAuthType
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func UnbindAuth(userID, authType, authTypeID, userName string) (err error) {
|
func UnbindAuth(userID, authType, authTypeID, userName string) (err error) {
|
||||||
globals.SugarLogger.Debugf("UnbindAuth userID:%s, authType:%s, authTypeID:%s, userName:%s", userID, authType, authTypeID, userName)
|
globals.SugarLogger.Debugf("UnbindAuth userID:%s, authType:%s, authTypeID:%s, userName:%s", userID, authType, authTypeID, userName)
|
||||||
if handler := authers[authType]; handler != nil {
|
if handler := authers[authType]; handler != nil {
|
||||||
|
|||||||
@@ -271,6 +271,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 删除认证方式
|
// @Title 删除认证方式
|
||||||
// @Description 删除认证方式
|
// @Description 删除认证方式
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
|
|||||||
@@ -16,6 +16,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "AddAuthBindWithMobile",
|
||||||
|
Router: "/AddAuthBindWithMobile",
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "ChangePassword",
|
Method: "ChangePassword",
|
||||||
|
|||||||
Reference in New Issue
Block a user