summaryrefslogtreecommitdiffstats
path: root/routers/home.go
diff options
context:
space:
mode:
author赵智超 <1012112796@qq.com>2020-09-16 07:49:34 +0800
committerGitHub <noreply@github.com>2020-09-15 19:49:34 -0400
commitec5677b7a2f56e124eaaa53291e21d6260354c12 (patch)
treec2b51f68e6a21301c4d497419d06d627172448ec /routers/home.go
parent07995e23018b5aa3906884f3c80ea5181250121e (diff)
downloadgitea-ec5677b7a2f56e124eaaa53291e21d6260354c12.tar.gz
gitea-ec5677b7a2f56e124eaaa53291e21d6260354c12.zip
Simplify CheckUnitUser logic (#12854)
if check one user's unit in different repos, it's not necessary to get user data every time. Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'routers/home.go')
-rw-r--r--routers/home.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/routers/home.go b/routers/home.go
index 5425670878..d37bf8e31b 100644
--- a/routers/home.go
+++ b/routers/home.go
@@ -303,10 +303,8 @@ func ExploreCode(ctx *context.Context) {
repoIDs []int64
err error
isAdmin bool
- userID int64
)
if ctx.User != nil {
- userID = ctx.User.ID
isAdmin = ctx.User.IsAdmin
}
@@ -336,7 +334,7 @@ func ExploreCode(ctx *context.Context) {
var rightRepoMap = make(map[int64]*models.Repository, len(repoMaps))
repoIDs = make([]int64, 0, len(repoMaps))
for id, repo := range repoMaps {
- if repo.CheckUnitUser(userID, isAdmin, models.UnitTypeCode) {
+ if repo.CheckUnitUser(ctx.User, models.UnitTypeCode) {
rightRepoMap[id] = repo
repoIDs = append(repoIDs, id)
}