From a07ab924d32a6a2258539f53ba2875afa1e070bf Mon Sep 17 00:00:00 2001 From: nickago Date: Wed, 29 Jul 2015 09:42:13 -0700 Subject: Added a unique error message for bad username and simplified error outputed to user --- store/sql_user_store.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'store') diff --git a/store/sql_user_store.go b/store/sql_user_store.go index cd63e95b8..19b61d8f9 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -161,7 +161,11 @@ 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(), "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 { -- cgit v1.2.3-1-g7c22 From 7cdd91687c0e163dd867a11fb56fd7fbac9879d2 Mon Sep 17 00:00:00 2001 From: nickago Date: Wed, 29 Jul 2015 10:45:33 -0700 Subject: Added error safety and a unique message for duplicate emails --- store/sql_user_store.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'store') 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()) -- cgit v1.2.3-1-g7c22