Skip to content

Commit

Permalink
Return 404 when user is not found on avatar (#21476)
Browse files Browse the repository at this point in the history
- 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 11d3677 commit 5d3dbff
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 5d3dbff

Please sign in to comment.