summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-07-30 08:49:36 -0400
committerChristopher Speller <crspeller@gmail.com>2015-07-30 08:49:36 -0400
commit4646c22ef185234a12937f7f3a5e036e5779417f (patch)
treeb55d5a476ba8477ed8192712d45b992762603e9c /store
parentb2b6bddadc6331d0f183f10da556b34f46314f73 (diff)
parent7cdd91687c0e163dd867a11fb56fd7fbac9879d2 (diff)
downloadchat-4646c22ef185234a12937f7f3a5e036e5779417f.tar.gz
chat-4646c22ef185234a12937f7f3a5e036e5779417f.tar.bz2
chat-4646c22ef185234a12937f7f3a5e036e5779417f.zip
Merge pull request #281 from nickago/MM-1600
MM-1600 Improve quality of error returned upon a duplicate username request
Diffstat (limited to 'store')
-rw-r--r--store/sql_user_store.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index cd63e95b8..552d12843 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -161,7 +161,13 @@ func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreCha
}
if count, err := us.GetMaster().Update(user); err != nil {
- result.Err = model.NewAppError("SqlUserStore.Update", "We encounted an error updating the account", "user_id="+user.Id+", "+err.Error())
+ 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())
+ }
} else if count != 1 {
result.Err = model.NewAppError("SqlUserStore.Update", "We couldn't update the account", fmt.Sprintf("user_id=%v, count=%v", user.Id, count))
} else {