Skip to content

Commit 35f68af

Browse files
committed
Fix errors
now what?
1 parent 7410534 commit 35f68af

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

routers/api/v1/api.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -459,22 +459,23 @@ func reqRepoWriter(unitTypes ...unit.Type) func(ctx *context.APIContext) {
459459
// statuses, or write to a repo, or be a site admin
460460
func reqRepoCommitStatusWriter(unitTypes ...unit.Type) func(ctx *context.APIContext) {
461461
return func(ctx *context.APIContext) {
462-
// TODO
462+
// TODO(not7cd)
463463
if !ctx.IsUserRepoWriter(unitTypes) && !ctx.IsUserRepoAdmin() && !ctx.IsUserSiteAdmin() {
464-
ctx.Error(http.StatusForbidden, "reqRepoCommitStatusWriter", "user should have a permission to write to a repo")
464+
ctx.APIError(http.StatusForbidden, "user should have a permission to write to a repo")
465465
return
466466
}
467467
}
468468
}
469469

470-
// reqRepoBranchWriter user should have a permission to write to a branch, or be a site admin
471-
func reqRepoBranchWriter(ctx *context.APIContext) {
472-
options, ok := web.GetForm(ctx).(api.FileOptionInterface)
473-
if !ok || (!ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, options.Branch()) && !ctx.IsUserSiteAdmin()) {
474-
ctx.Error(http.StatusForbidden, "reqRepoBranchWriter", "user should have a permission to write to this branch")
475-
return
476-
}
477-
}
470+
// TODO(not7cd): do I need this?
471+
// // reqRepoBranchWriter user should have a permission to write to a branch, or be a site admin
472+
// func reqRepoBranchWriter(ctx *context.APIContext) {
473+
// options, ok := web.GetForm(ctx).(api.FileOptionInterface)
474+
// if !ok || (!ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, options.Branch()) && !ctx.IsUserSiteAdmin()) {
475+
// ctx.APIError(http.StatusForbidden, "user should have a permission to write to this branch")
476+
// return
477+
// }
478+
// }
478479

479480
// reqRepoReader user should have specific read permission or be a repo admin or a site admin
480481
func reqRepoReader(unitType unit.Type) func(ctx *context.APIContext) {
@@ -490,9 +491,9 @@ func reqRepoReader(unitType unit.Type) func(ctx *context.APIContext) {
490491
// repo read permission, or be a repo admin or a site admin
491492
func reqRepoCommitStatusReader(unitType unit.Type) func(ctx *context.APIContext) {
492493
return func(ctx *context.APIContext) {
493-
// TODO
494+
// TODO(not7cd)
494495
if !ctx.Repo.CanRead(unitType) && !ctx.IsUserRepoAdmin() && !ctx.IsUserSiteAdmin() {
495-
ctx.Error(http.StatusForbidden, "reqRepoCommitStatusReader", "user should have specific read permission or be a repo admin or a site admin")
496+
ctx.APIError(http.StatusForbidden, "user should have specific read permission or be a repo admin or a site admin")
496497
return
497498
}
498499
}

0 commit comments

Comments
 (0)