From 8f49b1232a0e65b250293f4b39defd94cb35b949 Mon Sep 17 00:00:00 2001 From: John Olheiser <42128690+jolheiser@users.noreply.github.com> Date: Wed, 20 Nov 2019 13:44:35 -0600 Subject: [PATCH] Fix nil context user (#9099) Signed-off-by: jolheiser --- modules/context/repo.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 } }