修改运行器创建权限bug
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user