mirror of
https://github.com/go-gitea/gitea.git
synced 2025-12-10 17:35:25 +01:00
Fix errors
now what?
This commit is contained in:
parent
7410534629
commit
35f68afdf6
@ -459,22 +459,23 @@ func reqRepoWriter(unitTypes ...unit.Type) func(ctx *context.APIContext) {
|
|||||||
// statuses, or write to a repo, or be a site admin
|
// statuses, or write to a repo, or be a site admin
|
||||||
func reqRepoCommitStatusWriter(unitTypes ...unit.Type) func(ctx *context.APIContext) {
|
func reqRepoCommitStatusWriter(unitTypes ...unit.Type) func(ctx *context.APIContext) {
|
||||||
return func(ctx *context.APIContext) {
|
return func(ctx *context.APIContext) {
|
||||||
// TODO
|
// TODO(not7cd)
|
||||||
if !ctx.IsUserRepoWriter(unitTypes) && !ctx.IsUserRepoAdmin() && !ctx.IsUserSiteAdmin() {
|
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
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reqRepoBranchWriter user should have a permission to write to a branch, or be a site admin
|
// TODO(not7cd): do I need this?
|
||||||
func reqRepoBranchWriter(ctx *context.APIContext) {
|
// // reqRepoBranchWriter user should have a permission to write to a branch, or be a site admin
|
||||||
options, ok := web.GetForm(ctx).(api.FileOptionInterface)
|
// func reqRepoBranchWriter(ctx *context.APIContext) {
|
||||||
if !ok || (!ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, options.Branch()) && !ctx.IsUserSiteAdmin()) {
|
// options, ok := web.GetForm(ctx).(api.FileOptionInterface)
|
||||||
ctx.Error(http.StatusForbidden, "reqRepoBranchWriter", "user should have a permission to write to this branch")
|
// if !ok || (!ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, options.Branch()) && !ctx.IsUserSiteAdmin()) {
|
||||||
return
|
// 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
|
// 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) {
|
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
|
// repo read permission, or be a repo admin or a site admin
|
||||||
func reqRepoCommitStatusReader(unitType unit.Type) func(ctx *context.APIContext) {
|
func reqRepoCommitStatusReader(unitType unit.Type) func(ctx *context.APIContext) {
|
||||||
return func(ctx *context.APIContext) {
|
return func(ctx *context.APIContext) {
|
||||||
// TODO
|
// TODO(not7cd)
|
||||||
if !ctx.Repo.CanRead(unitType) && !ctx.IsUserRepoAdmin() && !ctx.IsUserSiteAdmin() {
|
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
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user