0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-12-09 00:21:31 +01:00

Fix errors

now what?
This commit is contained in:
Norbert Szulc 2025-08-29 21:31:52 +00:00
parent 7410534629
commit 35f68afdf6

View File

@ -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
}
}