- 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

@@ -38,6 +38,24 @@ func (*UserProvider) GetUser(authID, authIDType string) (user auth2.IUser) {
return user
}
func (*UserProvider) UpdateUserMobile(userID string, mobile string) (err error) {
_, err = dao.UpdateEntityLogically(dao.GetDB(), &model.User{}, map[string]interface{}{
"Mobile": mobile,
}, "admin", map[string]interface{}{
"UserID": userID,
})
return err
}
func (*UserProvider) UpdateUserEmail(userID string, email string) (err error) {
_, err = dao.UpdateEntityLogically(dao.GetDB(), &model.User{}, map[string]interface{}{
"Email": email,
}, "admin", map[string]interface{}{
"UserID": userID,
})
return err
}
func init() {
auth2.Init(userProvider)
}
@@ -77,21 +95,3 @@ func GetUserBindAuthInfo(ctx *jxcontext.Context) (authList []*model.AuthBind, er
}
return nil, err
}
func ChangeMobile2(ctx *jxcontext.Context, mobile, mobileVerifyCode string) (err error) {
authInfo, err := ctx.GetV2AuthInfo()
if err == nil {
mobileAuth, err2 := auth2.Login(auth2.AuthTypeMobile, mobile, auth2.UserIDMobile, mobileVerifyCode)
if err = err2; err == nil {
if mobileAuth.IUser != nil && authInfo.GetID() != mobileAuth.GetID() {
return errors.New("手机号已经存在")
}
_, err = dao.UpdateEntityLogically(dao.GetDB(), &model.User{}, map[string]interface{}{
"Mobile": mobile,
}, ctx.GetUserName(), map[string]interface{}{
"UserID": authInfo.GetID(),
})
}
}
return err
}