diff options
author | nickago <ngonella@calpoly.edu> | 2015-07-29 10:45:33 -0700 |
---|---|---|
committer | nickago <ngonella@calpoly.edu> | 2015-07-29 10:45:33 -0700 |
commit | 7cdd91687c0e163dd867a11fb56fd7fbac9879d2 (patch) | |
tree | 01a6ea495a5b9ead1e633ccfb059d6f6598563ea /store | |
parent | a07ab924d32a6a2258539f53ba2875afa1e070bf (diff) | |
download | chat-7cdd91687c0e163dd867a11fb56fd7fbac9879d2.tar.gz chat-7cdd91687c0e163dd867a11fb56fd7fbac9879d2.tar.bz2 chat-7cdd91687c0e163dd867a11fb56fd7fbac9879d2.zip |
Added error safety and a unique message for duplicate emails
Diffstat (limited to 'store')
-rw-r--r-- | store/sql_user_store.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go index 19b61d8f9..552d12843 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -161,7 +161,9 @@ func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreCha } if count, err := us.GetMaster().Update(user); err != nil { - if IsUniqueConstraintError(err.Error(), "Username", "users_username_teamid_key") { + if IsUniqueConstraintError(err.Error(), "Email", "users_email_teamid_key") { + result.Err = model.NewAppError("SqlUserStore.Update", "This email is already taken. Please choose another", "user_id="+user.Id+", "+err.Error()) + } else if IsUniqueConstraintError(err.Error(), "Username", "users_username_teamid_key") { result.Err = model.NewAppError("SqlUserStore.Update", "This username is already taken. Please choose another.", "user_id="+user.Id+", "+err.Error()) } else { result.Err = model.NewAppError("SqlUserStore.Update", "We encounted an error updating the account", "user_id="+user.Id+", "+err.Error()) |