From 97622f8a131fda2f6d083ab3724e02b3d0b3a19a Mon Sep 17 00:00:00 2001 From: jolheiser Date: Wed, 20 Nov 2019 12:50:50 -0600 Subject: [PATCH] Fix nil context user 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 f41505e7acf75..4c32e846eb1cb 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 } }