Skip to content

Commit

Permalink
Return 404 when user is not found on avatar (#21476) (#21477)
Browse files Browse the repository at this point in the history
- Backport #21476
- Instead of returning a 500 Internal Server when the user wasn't found,
return 404 Not found.
  • Loading branch information
Gusted authored Oct 16, 2022
1 parent f48fda8 commit 3f03275
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions routers/web/user/avatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 3f03275

Please sign in to comment.