diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index c2ff7d7b45..d83da47981 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -459,22 +459,23 @@ func reqRepoWriter(unitTypes ...unit.Type) func(ctx *context.APIContext) { // statuses, or write to a repo, or be a site admin func reqRepoCommitStatusWriter(unitTypes ...unit.Type) func(ctx *context.APIContext) { return func(ctx *context.APIContext) { - // TODO + // TODO(not7cd) if !ctx.IsUserRepoWriter(unitTypes) && !ctx.IsUserRepoAdmin() && !ctx.IsUserSiteAdmin() { - ctx.Error(http.StatusForbidden, "reqRepoCommitStatusWriter", "user should have a permission to write to a repo") + ctx.APIError(http.StatusForbidden, "user should have a permission to write to a repo") return } } } -// reqRepoBranchWriter user should have a permission to write to a branch, or be a site admin -func reqRepoBranchWriter(ctx *context.APIContext) { - options, ok := web.GetForm(ctx).(api.FileOptionInterface) - if !ok || (!ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, options.Branch()) && !ctx.IsUserSiteAdmin()) { - ctx.Error(http.StatusForbidden, "reqRepoBranchWriter", "user should have a permission to write to this branch") - return - } -} +// TODO(not7cd): do I need this? +// // reqRepoBranchWriter user should have a permission to write to a branch, or be a site admin +// func reqRepoBranchWriter(ctx *context.APIContext) { +// options, ok := web.GetForm(ctx).(api.FileOptionInterface) +// if !ok || (!ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, options.Branch()) && !ctx.IsUserSiteAdmin()) { +// ctx.APIError(http.StatusForbidden, "user should have a permission to write to this branch") +// return +// } +// } // reqRepoReader user should have specific read permission or be a repo admin or a site admin func reqRepoReader(unitType unit.Type) func(ctx *context.APIContext) { @@ -490,9 +491,9 @@ func reqRepoReader(unitType unit.Type) func(ctx *context.APIContext) { // repo read permission, or be a repo admin or a site admin func reqRepoCommitStatusReader(unitType unit.Type) func(ctx *context.APIContext) { return func(ctx *context.APIContext) { - // TODO + // TODO(not7cd) if !ctx.Repo.CanRead(unitType) && !ctx.IsUserRepoAdmin() && !ctx.IsUserSiteAdmin() { - ctx.Error(http.StatusForbidden, "reqRepoCommitStatusReader", "user should have specific read permission or be a repo admin or a site admin") + ctx.APIError(http.StatusForbidden, "user should have specific read permission or be a repo admin or a site admin") return } }