mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-06-22 10:02:15 +00:00
24 lines
597 B
Go
24 lines
597 B
Go
// Copyright 2026 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package permissions
|
|
|
|
import (
|
|
"net/http"
|
|
"slices"
|
|
|
|
"forgejo.org/models/unit"
|
|
)
|
|
|
|
func ReqOwner(ctx Context, unitTypes []unit.Type) {
|
|
if len(unitTypes) > 0 && !slices.ContainsFunc(unitTypes, func(unitType unit.Type) bool {
|
|
return ctx.GetRepository().UnitEnabled(ctx.GetContext(), unitType)
|
|
}) {
|
|
ctx.NotFound()
|
|
return
|
|
}
|
|
if !ctx.GetPermission().IsOwner() && !IsUserSiteAdmin(ctx) {
|
|
ctx.Error(http.StatusForbidden, "reqOwner", "user should be the owner of the repo")
|
|
return
|
|
}
|
|
}
|