]> source.dussan.org Git - gitea.git/commitdiff
Fix nil context user (#9099)
authorJohn Olheiser <42128690+jolheiser@users.noreply.github.com>
Wed, 20 Nov 2019 19:44:35 +0000 (13:44 -0600)
committerzeripath <art27@cantab.net>
Wed, 20 Nov 2019 19:44:35 +0000 (19:44 +0000)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
modules/context/repo.go

index f41505e7acf755431a0f6110debd401ce2e8e1ad..4c32e846eb1cb1997bdf45c796a90ee22c6027c4 100644 (file)
@@ -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
        }
 }