diff options
author | 6543 <6543@obermui.de> | 2019-12-29 15:24:50 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-12-29 16:24:50 +0200 |
commit | d59536c222857713d95846d77903282afe608f23 (patch) | |
tree | f75b7f5df55bb18a9b7d3f88f8effedd3b893e18 /routers | |
parent | ae9d342f5413031ed01eb74e7c7640ffa2cff13e (diff) | |
download | gitea-d59536c222857713d95846d77903282afe608f23.tar.gz gitea-d59536c222857713d95846d77903282afe608f23.zip |
[BugFix] use default avatar for ghost user (fix 500 error) (#9536)
* remove since it is there for 3years
* fix 500 error for ghost avatar
* dont insert "-1" in any case to issue.poster_id
* fix lint
* Test: ghost avatar link
* fix test
* Revert "remove since it is there for 3years"
This reverts commit fd9ad05159c84ba804b126d2a959963d82578b22.
* Revert "dont insert "-1" in any case to issue.poster_id"
This reverts commit 05469ab6d815a6cc6478a256018b9ed1a12749e0.
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/user/avatar.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/routers/user/avatar.go b/routers/user/avatar.go index 20597c72ff..045206c50a 100644 --- a/routers/user/avatar.go +++ b/routers/user/avatar.go @@ -6,6 +6,7 @@ package user import ( "strconv" + "strings" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" @@ -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)) |