This commit is contained in:
suyl
2021-04-27 09:30:11 +08:00
parent e5d02223b7
commit 5590c170b9
2 changed files with 21 additions and 0 deletions

View File

@@ -344,6 +344,18 @@ func AddAuthBind(user IUser, newAuthInfo *AuthInfo) (err error) {
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) {
globals.SugarLogger.Debugf("UnbindAuth userID:%s, authType:%s, authTypeID:%s, userName:%s", userID, authType, authTypeID, userName)
if handler := authers[authType]; handler != nil {

View File

@@ -142,6 +142,15 @@ func init() {
Filters: nil,
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"],
web.ControllerComments{
Method: "AddAuthBindWithMobile",
Router: `/AddAuthBindWithMobile`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:Auth2Controller"],
web.ControllerComments{
Method: "ChangePassword",