fix toast message is wrong when modify email to an existed one
This commit is contained in:
@@ -5,7 +5,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrDatabaseTypeInvalid = NewSystemError(SYSTEM_SUBCATEGORY_DATABASE, 0, http.StatusInternalServerError, "database type is invalid")
|
||||
ErrDatabaseHostInvalid = NewSystemError(SYSTEM_SUBCATEGORY_DATABASE, 1, http.StatusInternalServerError, "database host is invalid")
|
||||
ErrDatabaseIsNull = NewSystemError(SYSTEM_SUBCATEGORY_DATABASE, 2, http.StatusInternalServerError, "database cannot be null")
|
||||
ErrDatabaseTypeInvalid = NewSystemError(SYSTEM_SUBCATEGORY_DATABASE, 0, http.StatusInternalServerError, "database type is invalid")
|
||||
ErrDatabaseHostInvalid = NewSystemError(SYSTEM_SUBCATEGORY_DATABASE, 1, http.StatusInternalServerError, "database host is invalid")
|
||||
ErrDatabaseIsNull = NewSystemError(SYSTEM_SUBCATEGORY_DATABASE, 2, http.StatusInternalServerError, "database cannot be null")
|
||||
ErrDatabaseOperationFailed = NewSystemError(SYSTEM_SUBCATEGORY_DATABASE, 3, http.StatusInternalServerError, "database operation failed")
|
||||
)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -174,6 +174,7 @@ export default {
|
||||
'error': {
|
||||
'system error': 'System Error',
|
||||
'api not found': 'Failed to request api',
|
||||
'database operation failed': 'Database operation failed',
|
||||
'incomplete or incorrect submission': 'Incomplete or incorrect submission',
|
||||
'operation failed': 'Operation failed',
|
||||
'nothing will be updated': 'Nothing will be updated',
|
||||
|
||||
@@ -174,6 +174,7 @@ export default {
|
||||
'error': {
|
||||
'system error': '系统错误',
|
||||
'api not found': '接口调用失败',
|
||||
'database operation failed': '数据库操作失败',
|
||||
'incomplete or incorrect submission': '提交不完整或不正确',
|
||||
'operation failed': '操作失败',
|
||||
'nothing will be updated': '没有内容更新',
|
||||
|
||||
Reference in New Issue
Block a user