From eabbddcd98717ef20d8475e819f403c50f4a9787 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 28 Nov 2018 19:26:14 +0800 Subject: Restrict permission check on repositories and fix some problems (#5314) * fix units permission problems * fix some bugs and merge LoadUnits to repoAssignment * refactor permission struct and add some copyright heads * remove unused codes * fix routes units check * improve permission check * add unit tests for permission * fix typo * fix tests * fix some routes * fix api permission check * improve permission check * fix some permission check * fix tests * fix tests * improve some permission check * fix some permission check * refactor AccessLevel * fix bug * fix tests * fix tests * fix tests * fix AccessLevel * rename CanAccess * fix tests * fix comment * fix bug * add missing unit for test repos * fix bug * rename some functions * fix routes check --- routers/repo/branch.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'routers/repo/branch.go') diff --git a/routers/repo/branch.go b/routers/repo/branch.go index 7b1e2a8bbe..295aeaa24b 100644 --- a/routers/repo/branch.go +++ b/routers/repo/branch.go @@ -1,4 +1,5 @@ // Copyright 2014 The Gogs Authors. All rights reserved. +// Copyright 2018 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -33,7 +34,7 @@ func Branches(ctx *context.Context) { ctx.Data["Title"] = "Branches" ctx.Data["IsRepoToolbarBranches"] = true ctx.Data["DefaultBranch"] = ctx.Repo.Repository.DefaultBranch - ctx.Data["IsWriter"] = ctx.Repo.IsWriter() + ctx.Data["IsWriter"] = ctx.Repo.CanWrite(models.UnitTypeCode) ctx.Data["IsMirror"] = ctx.Repo.Repository.IsMirror ctx.Data["PageIsViewCode"] = true ctx.Data["PageIsBranches"] = true @@ -161,7 +162,7 @@ func loadBranches(ctx *context.Context) []*Branch { } } - if ctx.Repo.IsWriter() { + if ctx.Repo.CanWrite(models.UnitTypeCode) { deletedBranches, err := getDeletedBranches(ctx) if err != nil { ctx.ServerError("getDeletedBranches", err) -- cgit v1.2.3