修改运行器创建权限bug

This commit is contained in:
vecmatex
2025-11-19 15:42:25 +08:00
repo.diff.parent 56a4039034
repo.diff.commit b8303e9000
repo.diff.stats_desc%!(EXTRA int=2, int=10, int=1)

repo.diff.view_file

@@ -160,6 +160,7 @@ func Runners(ctx *context.Context) {
ctx.Data["RunnerOwnerID"] = opts.OwnerID
ctx.Data["RunnerRepoID"] = opts.RepoID
ctx.Data["SortType"] = opts.Sort
ctx.Data["AllowCreateActRunner"] = ctx.Doer.AllowCreateActRunner
pager := context.NewPagination(int(count), opts.PageSize, opts.Page, 5)
@@ -300,6 +301,14 @@ func RegisterARunner(ctx *context.Context) {
ctx.ServerError("getRunnersCtx", err)
return
}
// 检查用户是否有权创建 runner
if !ctx.Doer.AllowCreateActRunner {
ctx.Flash.Error(ctx.Tr("actions.runners.create_runner_permission_denied"))
ctx.Redirect(rCtx.RedirectLink)
return
}
token, err := actions_model.NewRunnerToken(ctx, rCtx.OwnerID, rCtx.RepoID)
if err != nil {
ctx.ServerError("NewRunnerToken", err)

repo.diff.view_file

@@ -9,7 +9,7 @@
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
</button>
<div class="menu">
{{if or (.AllowCreateActRunner) (.Permission.IsAdmin)}}
{{if or (.AllowCreateActRunner)}}
<div class="item">
<a href="{{$.Link}}/regist_runner">{{ctx.Locale.Tr "actions.runners.regist_runner"}}</a>
</div>