diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-07-30 08:49:36 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-07-30 08:49:36 -0400 |
commit | 4646c22ef185234a12937f7f3a5e036e5779417f (patch) | |
tree | b55d5a476ba8477ed8192712d45b992762603e9c | |
parent | b2b6bddadc6331d0f183f10da556b34f46314f73 (diff) | |
parent | 7cdd91687c0e163dd867a11fb56fd7fbac9879d2 (diff) | |
download | chat-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
-rw-r--r-- | store/sql_user_store.go | 8 | ||||
-rw-r--r-- | web/react/components/user_settings.jsx | 6 |
2 files changed, 12 insertions, 2 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 { diff --git a/web/react/components/user_settings.jsx b/web/react/components/user_settings.jsx index e1ae6da52..e7ac08a94 100644 --- a/web/react/components/user_settings.jsx +++ b/web/react/components/user_settings.jsx @@ -709,7 +709,11 @@ var GeneralTab = React.createClass({ }.bind(this), function(err) { state = this.getInitialState(); - state.server_error = err; + if(err.message) { + state.server_error = err.message; + } else { + state.server_error = err + } this.setState(state); }.bind(this) ); |