From c1059facef26b9dd1027e9877f95cefd0e8866c1 Mon Sep 17 00:00:00 2001 From: Guan Xiying Date: Wed, 25 Aug 2021 10:44:06 +0800 Subject: [PATCH] * Check gitlab token when create gitlab job. --- module/job/control.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/module/job/control.php b/module/job/control.php index f4dbcfa130..634db24b55 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -102,7 +102,14 @@ class job extends control if(empty($repo->synced)) continue; $repoPairs[$repo->id] = $repo->name; $repoTypes[$repo->id] = $repo->SCM; - if(strtolower($repo->SCM) == 'gitlab') $gitlabRepos[$repo->id] = $repo->name; + if(strtolower($repo->SCM) == 'gitlab') + { + $gitlab = $this->loadModel('gitlab')->getByID($repo->gitlab); + $tokenUser = $this->gitlab->apiGetCurrentUser($gitlab->url, $gitlab->token); + if(!isset($tokenUser->is_admin) or !$tokenUser->is_admin) continue; + $gitlabRepos[$repo->id] = $repo->name; + } + } $this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->job->create;