fix toast message is wrong when modify email to an existed one
This commit is contained in:
@@ -157,6 +157,14 @@ func (s *UserService) UpdateUser(user *models.User) (keyProfileUpdated bool, err
|
||||
keyProfileUpdated = false
|
||||
|
||||
if user.Email != "" {
|
||||
exists, err := s.ExistsEmail(user.Email)
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
} else if exists {
|
||||
return false, errs.ErrUserEmailAlreadyExists
|
||||
}
|
||||
|
||||
user.EmailVerified = false
|
||||
|
||||
updateCols = append(updateCols, "email")
|
||||
@@ -184,6 +192,10 @@ func (s *UserService) UpdateUser(user *models.User) (keyProfileUpdated bool, err
|
||||
err = s.UserDB().DoTransaction(func(sess *xorm.Session) error {
|
||||
updatedRows, err := sess.ID(user.Uid).Where("deleted=?", false).Cols(updateCols...).Update(user)
|
||||
|
||||
if err != nil {
|
||||
return errs.ErrDatabaseOperationFailed
|
||||
}
|
||||
|
||||
if updatedRows < 1 {
|
||||
return errs.ErrUserNotFound
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user