diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-01-30 08:30:02 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-30 08:30:02 -0500 |
commit | c01d9ad6cf3f8bb2ad4145441816598d8ffa2d9e (patch) | |
tree | f995a08e296b5088df2a882ab70251c7b2b8cfe7 /store/sql_user_store.go | |
parent | 3e2f879b77b9b9d089bc8f83304b8b21b83c5bd9 (diff) | |
download | chat-c01d9ad6cf3f8bb2ad4145441816598d8ffa2d9e.tar.gz chat-c01d9ad6cf3f8bb2ad4145441816598d8ffa2d9e.tar.bz2 chat-c01d9ad6cf3f8bb2ad4145441816598d8ffa2d9e.zip |
Implement APIv4 infrastructure (#5191)
* Implement APIv4 infrastructure
* Update parameter requirement functions per feedback
Diffstat (limited to 'store/sql_user_store.go')
-rw-r--r-- | store/sql_user_store.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go index 09742a4f4..02cbb3fbf 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -7,6 +7,7 @@ import ( "crypto/md5" "database/sql" "fmt" + "net/http" "strconv" "strings" @@ -108,9 +109,9 @@ func (us SqlUserStore) Save(user *model.User) StoreChannel { if err := us.GetMaster().Insert(user); err != nil { if IsUniqueConstraintError(err.Error(), []string{"Email", "users_email_key", "idx_users_email_unique"}) { - result.Err = model.NewLocAppError("SqlUserStore.Save", "store.sql_user.save.email_exists.app_error", nil, "user_id="+user.Id+", "+err.Error()) + result.Err = model.NewAppError("SqlUserStore.Save", "store.sql_user.save.email_exists.app_error", nil, "user_id="+user.Id+", "+err.Error(), http.StatusBadRequest) } else if IsUniqueConstraintError(err.Error(), []string{"Username", "users_username_key", "idx_users_username_unique"}) { - result.Err = model.NewLocAppError("SqlUserStore.Save", "store.sql_user.save.username_exists.app_error", nil, "user_id="+user.Id+", "+err.Error()) + result.Err = model.NewAppError("SqlUserStore.Save", "store.sql_user.save.username_exists.app_error", nil, "user_id="+user.Id+", "+err.Error(), http.StatusBadRequest) } else { result.Err = model.NewLocAppError("SqlUserStore.Save", "store.sql_user.save.app_error", nil, "user_id="+user.Id+", "+err.Error()) } @@ -389,6 +390,7 @@ func (us SqlUserStore) Get(id string) StoreChannel { result.Err = model.NewLocAppError("SqlUserStore.Get", "store.sql_user.get.app_error", nil, "user_id="+id+", "+err.Error()) } else if obj == nil { result.Err = model.NewLocAppError("SqlUserStore.Get", MISSING_ACCOUNT_ERROR, nil, "user_id="+id) + result.Err.StatusCode = http.StatusNotFound } else { result.Data = obj.(*model.User) } |