diff options
author | John Olheiser <42128690+jolheiser@users.noreply.github.com> | 2019-11-20 13:44:35 -0600 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-11-20 19:44:35 +0000 |
commit | 8f49b1232a0e65b250293f4b39defd94cb35b949 (patch) | |
tree | aec498dde75a9a9d24ccd84953a74306cb0e027c /modules/context/repo.go | |
parent | 1615b3c1874932c08d504fcc111f46105a2207b6 (diff) | |
download | gitea-8f49b1232a0e65b250293f4b39defd94cb35b949.tar.gz gitea-8f49b1232a0e65b250293f4b39defd94cb35b949.zip |
Fix nil context user (#9099)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Diffstat (limited to 'modules/context/repo.go')
-rw-r--r-- | modules/context/repo.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go index f41505e7ac..4c32e846eb 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -204,7 +204,13 @@ func RetrieveTemplateRepo(ctx *Context, repo *models.Repository) { return } - if !repo.TemplateRepo.CheckUnitUser(ctx.User.ID, ctx.User.IsAdmin, models.UnitTypeCode) { + perm, err := models.GetUserRepoPermission(repo.TemplateRepo, ctx.User) + if err != nil { + ctx.ServerError("GetUserRepoPermission", err) + return + } + + if !perm.CanRead(models.UnitTypeCode) { repo.TemplateID = 0 } } |