aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-09-28 21:13:04 +0800
committerGitHub <noreply@github.com>2021-09-28 21:13:04 +0800
commit37b29319aaab085001def4bc33b690c9a7a8eb19 (patch)
treecdefb2a16aa2faf2d2e359eb9ea7048c6727d234 /routers/web
parenta82c799fc81cc9d2611aa9b27d531ee4a23152b3 (diff)
downloadgitea-37b29319aaab085001def4bc33b690c9a7a8eb19.tar.gz
gitea-37b29319aaab085001def4bc33b690c9a7a8eb19.zip
Fix bug of get context user (#17169)
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'routers/web')
-rw-r--r--routers/web/base.go11
1 files changed, 1 insertions, 10 deletions
diff --git a/routers/web/base.go b/routers/web/base.go
index 9238ea2173..f50c5229b1 100644
--- a/routers/web/base.go
+++ b/routers/web/base.go
@@ -14,7 +14,6 @@ import (
"path/filepath"
"strings"
- "code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/httpcache"
"code.gitea.io/gitea/modules/log"
@@ -147,15 +146,7 @@ func Recovery() func(next http.Handler) http.Handler {
"i18n": lc,
}
- var user *models.User
- if apiContext := context.GetAPIContext(req); apiContext != nil {
- user = apiContext.User
- }
- if user == nil {
- if ctx := context.GetContext(req); ctx != nil {
- user = ctx.User
- }
- }
+ var user = context.GetContextUser(req)
if user == nil {
// Get user from session if logged in - do not attempt to sign-in
user = auth.SessionUser(sessionStore)