]> source.dussan.org Git - gitea.git/commitdiff
Return 404 when user is not found on avatar (#21476) (#21477)
authorGusted <williamzijl7@hotmail.com>
Sun, 16 Oct 2022 16:56:58 +0000 (16:56 +0000)
committerGitHub <noreply@github.com>
Sun, 16 Oct 2022 16:56:58 +0000 (00:56 +0800)
- Backport #21476
- Instead of returning a 500 Internal Server when the user wasn't found,
return 404 Not found.

routers/web/user/avatar.go

index 53a603fab094d43e0da7ed1c56a1f6cf2779c43a..05896299d25ef373fd65627bc7c9e39dc782c592 100644 (file)
@@ -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
                }