mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 09:44:26 +08:00
fix toast message is wrong when modify email to an existed one
This commit is contained in:
@@ -5,7 +5,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrDatabaseTypeInvalid = NewSystemError(SYSTEM_SUBCATEGORY_DATABASE, 0, http.StatusInternalServerError, "database type is invalid")
|
ErrDatabaseTypeInvalid = NewSystemError(SYSTEM_SUBCATEGORY_DATABASE, 0, http.StatusInternalServerError, "database type is invalid")
|
||||||
ErrDatabaseHostInvalid = NewSystemError(SYSTEM_SUBCATEGORY_DATABASE, 1, http.StatusInternalServerError, "database host 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")
|
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
|
keyProfileUpdated = false
|
||||||
|
|
||||||
if user.Email != "" {
|
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
|
user.EmailVerified = false
|
||||||
|
|
||||||
updateCols = append(updateCols, "email")
|
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 {
|
err = s.UserDB().DoTransaction(func(sess *xorm.Session) error {
|
||||||
updatedRows, err := sess.ID(user.Uid).Where("deleted=?", false).Cols(updateCols...).Update(user)
|
updatedRows, err := sess.ID(user.Uid).Where("deleted=?", false).Cols(updateCols...).Update(user)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return errs.ErrDatabaseOperationFailed
|
||||||
|
}
|
||||||
|
|
||||||
if updatedRows < 1 {
|
if updatedRows < 1 {
|
||||||
return errs.ErrUserNotFound
|
return errs.ErrUserNotFound
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ export default {
|
|||||||
'error': {
|
'error': {
|
||||||
'system error': 'System Error',
|
'system error': 'System Error',
|
||||||
'api not found': 'Failed to request api',
|
'api not found': 'Failed to request api',
|
||||||
|
'database operation failed': 'Database operation failed',
|
||||||
'incomplete or incorrect submission': 'Incomplete or incorrect submission',
|
'incomplete or incorrect submission': 'Incomplete or incorrect submission',
|
||||||
'operation failed': 'Operation failed',
|
'operation failed': 'Operation failed',
|
||||||
'nothing will be updated': 'Nothing will be updated',
|
'nothing will be updated': 'Nothing will be updated',
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ export default {
|
|||||||
'error': {
|
'error': {
|
||||||
'system error': '系统错误',
|
'system error': '系统错误',
|
||||||
'api not found': '接口调用失败',
|
'api not found': '接口调用失败',
|
||||||
|
'database operation failed': '数据库操作失败',
|
||||||
'incomplete or incorrect submission': '提交不完整或不正确',
|
'incomplete or incorrect submission': '提交不完整或不正确',
|
||||||
'operation failed': '操作失败',
|
'operation failed': '操作失败',
|
||||||
'nothing will be updated': '没有内容更新',
|
'nothing will be updated': '没有内容更新',
|
||||||
|
|||||||
Reference in New Issue
Block a user