aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-10-16 18:48:17 +0000
committerGitHub <noreply@github.com>2022-10-16 19:48:17 +0100
commit5d3dbffa150d832d2f9aedd9f90ca91178a95f9c (patch)
treecb00185e3863e18067baef546867d80e3118655d
parent11d3677818df64df6cc8386c498169101dbdbb13 (diff)
downloadgitea-5d3dbffa150d832d2f9aedd9f90ca91178a95f9c.tar.gz
gitea-5d3dbffa150d832d2f9aedd9f90ca91178a95f9c.zip
Return 404 when user is not found on avatar (#21476)
- Instead of returning a 500 Internal Server when the user wasn't found, return 404 Not found
-rw-r--r--routers/web/user/avatar.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/routers/web/user/avatar.go b/routers/web/user/avatar.go
index 53a603fab0..05896299d2 100644
--- a/routers/web/user/avatar.go
+++ b/routers/web/user/avatar.go
@@ -31,6 +31,10 @@ func AvatarByUserName(ctx *context.Context) {
if strings.ToLower(userName) != "ghost" {
var err error
if user, err = user_model.GetUserByName(ctx, userName); err != nil {
+ if user_model.IsErrUserNotExist(err) {
+ ctx.NotFound("GetUserByName", err)
+ return
+ }
ctx.ServerError("Invalid user: "+userName, err)
return
}