mirror of
https://github.com/go-gitea/gitea.git
synced 2024-05-11 05:55:29 +00:00
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>
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user