Skip to content

Commit

Permalink
fix 500 error for ghost avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Dec 29, 2019
1 parent c0bb5eb commit 282d782
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions routers/user/avatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package user

import (
"strconv"
"strings"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
Expand All @@ -23,14 +24,19 @@ func Avatar(ctx *context.Context) {

log.Debug("Asked avatar for user %v and size %v", userName, size)

user, err := models.GetUserByName(userName)
if err != nil {
if models.IsErrUserNotExist(err) {
ctx.ServerError("Requested avatar for invalid user", err)
} else {
ctx.ServerError("Retrieving user by name", err)
var user *models.User
if strings.ToLower(userName) != "ghost" {
user, err = models.GetUserByName(userName)
if err != nil {
if models.IsErrUserNotExist(err) {
ctx.ServerError("Requested avatar for invalid user", err)
} else {
ctx.ServerError("Retrieving user by name", err)
}
return
}
return
} else {
user = models.NewGhostUser()
}

ctx.Redirect(user.RealSizedAvatarLink(size))
Expand Down

0 comments on commit 282d782

Please sign in to comment.