diff --git a/routers/web/shared/actions/runners.go b/routers/web/shared/actions/runners.go index aaf06a84b0..c00bba4a9e 100644 --- a/routers/web/shared/actions/runners.go +++ b/routers/web/shared/actions/runners.go @@ -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) diff --git a/templates/shared/actions/runner_list.tmpl b/templates/shared/actions/runner_list.tmpl index 968c8ef052..5b4708be26 100644 --- a/templates/shared/actions/runner_list.tmpl +++ b/templates/shared/actions/runner_list.tmpl @@ -9,7 +9,7 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}}