forgejo/routers/api/v1/permissions/must_enable_issues.go
2026-06-20 22:58:56 +02:00

32 lines
801 B
Go

// Copyright 2026 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
package permissions
import (
"forgejo.org/models/unit"
"forgejo.org/modules/log"
)
func MustEnableIssues(ctx Context) {
if !ctx.GetPermission().CanRead(unit.TypeIssues) {
if log.IsTrace() {
if ctx.GetIsSigned() {
log.Trace("Permission Denied: User %-v cannot read %-v in Repo %-v\n"+
"User in Repo has Permissions: %-+v",
ctx.GetDoer(),
unit.TypeIssues,
ctx.GetRepository(),
ctx.GetPermission())
} else {
log.Trace("Permission Denied: Anonymous user cannot read %-v in Repo %-v\n"+
"Anonymous user in Repo has Permissions: %-+v",
unit.TypeIssues,
ctx.GetRepository(),
ctx.GetPermission())
}
}
ctx.NotFound()
return
}
}