RegisterUser支持注册用户时,不指定手机号
This commit is contained in:
@@ -279,20 +279,9 @@ func Login(ctx *Context, authType, authID, authIDType, authSecret string) (authI
|
||||
|
||||
// 通过临时TOKEN绑定新创建的用户
|
||||
func BindUser(inauthInfo *AuthInfo, user IUser) (outauthInfo *AuthInfo, err error) {
|
||||
if inauthInfo == nil || user == nil {
|
||||
return nil, ErrInternalErrror
|
||||
}
|
||||
if !inauthInfo.IsUserEmpty() {
|
||||
return nil, ErrUserAlreadyExist
|
||||
}
|
||||
if handler := authers[inauthInfo.AuthBindInfo.Type]; handler != nil {
|
||||
if err = AddAuthBind(user, inauthInfo); err == nil {
|
||||
inauthInfo.AuthBindInfo.UserID = user.GetID()
|
||||
if err = handler.AddAuthBind(inauthInfo.AuthBindInfo, user.GetName()); err == nil {
|
||||
RemoveUserInfo(inauthInfo.Token)
|
||||
outauthInfo = createAuthInfo(user, inauthInfo.AuthBindInfo)
|
||||
}
|
||||
} else {
|
||||
err = ErrIllegalAuthType
|
||||
outauthInfo = createAuthInfo(user, inauthInfo.AuthBindInfo)
|
||||
}
|
||||
return outauthInfo, err
|
||||
}
|
||||
@@ -311,9 +300,13 @@ func AddAuthBind(user IUser, newAuthInfo *AuthInfo) (err error) {
|
||||
} else if newAuthInfo.AuthBindInfo.Type == AuthTypeEmail {
|
||||
err = userProvider.UpdateUserEmail(user.GetID(), newAuthInfo.AuthBindInfo.AuthID)
|
||||
} else {
|
||||
newAuthInfo.AuthBindInfo.UserID = user.GetID()
|
||||
authers[newAuthInfo.AuthBindInfo.Type].UnbindAuth(user.GetID(), newAuthInfo.GetAuthType(), user.GetName())
|
||||
err = authers[newAuthInfo.AuthBindInfo.Type].AddAuthBind(newAuthInfo.AuthBindInfo, user.GetName())
|
||||
if handler := authers[newAuthInfo.AuthBindInfo.Type]; handler != nil {
|
||||
newAuthInfo.AuthBindInfo.UserID = user.GetID()
|
||||
handler.UnbindAuth(user.GetID(), newAuthInfo.GetAuthType(), user.GetName())
|
||||
err = handler.AddAuthBind(newAuthInfo.AuthBindInfo, user.GetName())
|
||||
} else {
|
||||
err = ErrIllegalAuthType
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user