- remove user2.ChangeMobile (use auth2.AddAuthBind instead)

This commit is contained in:
gazebo
2019-03-05 10:24:42 +08:00
parent 02f49207f1
commit 273c50f6b7
5 changed files with 37 additions and 35 deletions

View File

@@ -51,6 +51,8 @@ type IUser interface {
type IUserProvider interface {
GetUser(authID, authIDType string) (user IUser)
UpdateUserMobile(userID string, mobile string) (err error)
UpdateUserEmail(userID string, email string) (err error)
}
type CaptchaInfo struct {
@@ -237,8 +239,14 @@ func AddAuthBind(authInfo *AuthInfo, newAuthInfo *AuthInfo) (err error) {
return ErrAuthTypeAlreadyExist
}
RemoveUserInfo(newAuthInfo.Token)
newAuthInfo.AuthBindInfo.UserID = authInfo.GetID()
err = authers[newAuthInfo.AuthBindInfo.Type].AddAuthBind(newAuthInfo.AuthBindInfo, authInfo.GetName())
if newAuthInfo.AuthBindInfo.Type == AuthTypeMobile {
err = userProvider.UpdateUserMobile(authInfo.GetID(), newAuthInfo.AuthBindInfo.AuthID)
} else if newAuthInfo.AuthBindInfo.Type == AuthTypeEmail {
err = userProvider.UpdateUserEmail(authInfo.GetID(), newAuthInfo.AuthBindInfo.AuthID)
} else {
newAuthInfo.AuthBindInfo.UserID = authInfo.GetID()
err = authers[newAuthInfo.AuthBindInfo.Type].AddAuthBind(newAuthInfo.AuthBindInfo, authInfo.GetName())
}
return err
}