diff options
Diffstat (limited to 'modules/middleware')
-rw-r--r-- | modules/middleware/context.go | 6 | ||||
-rw-r--r-- | modules/middleware/repo.go | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/modules/middleware/context.go b/modules/middleware/context.go index cd11c08b..cee5d100 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -84,12 +84,12 @@ func (r *RepoContext) IsAdmin() bool { return r.AccessMode >= models.ACCESS_MODE_ADMIN } -// IsPusher returns true if current user has write or higher access of repository. -func (r *RepoContext) IsPusher() bool { +// IsWriter returns true if current user has write or higher access of repository. +func (r *RepoContext) IsWriter() bool { return r.AccessMode >= models.ACCESS_MODE_WRITE } -// Return if the current user has read access for this repository +// HasAccess returns true if the current user has at least read access for this repository func (r *RepoContext) HasAccess() bool { return r.AccessMode >= models.ACCESS_MODE_READ } diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 7c99d2d0..3e1835f5 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -140,7 +140,7 @@ func RepoAssignment(args ...bool) macaron.Handler { ctx.Data["Owner"] = ctx.Repo.Repository.Owner ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner() ctx.Data["IsRepositoryAdmin"] = ctx.Repo.IsAdmin() - ctx.Data["IsRepositoryPusher"] = ctx.Repo.IsPusher() + ctx.Data["IsRepositoryWriter"] = ctx.Repo.IsWriter() if repo.IsFork { RetrieveBaseRepo(ctx, repo) @@ -150,7 +150,7 @@ func RepoAssignment(args ...bool) macaron.Handler { } // People who have push access and propose a new pull request. - if ctx.Repo.IsPusher() { + if ctx.Repo.IsWriter() { // Pull request is allowed if this is a fork repository // and base repository accepts pull requests. if repo.BaseRepo != nil { @@ -336,16 +336,16 @@ func RepoRef() macaron.Handler { func RequireRepoAdmin() macaron.Handler { return func(ctx *Context) { - if !ctx.Repo.IsAdmin() { + if !ctx.IsSigned || (!ctx.Repo.IsAdmin() && !ctx.User.IsAdmin) { ctx.Handle(404, ctx.Req.RequestURI, nil) return } } } -func RequireRepoPusher() macaron.Handler { +func RequireRepoWriter() macaron.Handler { return func(ctx *Context) { - if !ctx.Repo.IsPusher() { + if !ctx.IsSigned || (!ctx.Repo.IsWriter() && !ctx.User.IsAdmin) { ctx.Handle(404, ctx.Req.RequestURI, nil) return } |