Fix error handling when requesting profile image for bad user ID (#8618)

This commit is contained in:
Joram Wilander
2018-04-13 07:57:22 -07:00
committed by Christopher Speller
parent ae5e324be8
commit 21b1cd44e0
3 changed files with 9 additions and 1 deletions
+2 -1
View File
@@ -199,7 +199,8 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
return
} else {
if len(users) == 0 {
c.Err = err
c.Err = model.NewAppError("getProfileImage", "api.user.get_profile_image.not_found.app_error", nil, "", http.StatusNotFound)
return
}
user := users[0]
+3
View File
@@ -834,6 +834,9 @@ func TestGetProfileImage(t *testing.T) {
_, resp = Client.GetProfileImage("junk", "")
CheckBadRequestStatus(t, resp)
_, resp = Client.GetProfileImage(model.NewId(), "")
CheckNotFoundStatus(t, resp)
Client.Logout()
_, resp = Client.GetProfileImage(user.Id, "")
CheckUnauthorizedStatus(t, resp)
+4
View File
@@ -3094,6 +3094,10 @@
"id": "api.user.upload_profile_user.parse.app_error",
"translation": "Could not parse multipart form"
},
{
"id": "api.user.get_profile_image.not_found.app_error",
"translation": "Unable to get profile image, user not found."
},
{
"id": "api.user.upload_profile_user.storage.app_error",
"translation": "Unable to upload file. Image storage is not configured."