* Fix bug#14617.
This commit is contained in:
@@ -190,10 +190,13 @@ class gitlab extends control
|
||||
*/
|
||||
public function checkToken()
|
||||
{
|
||||
if(strpos($this->post->url, 'http') !== 0) return $this->send(array('result' => 'fail', 'message' => array('url' => array($this->lang->gitlab->hostError))));
|
||||
if(!$this->post->token) return $this->send(array('result' => 'fail', 'message' => array('token' => array($this->lang->gitlab->tokenError))));
|
||||
$gitlabURL = trim($this->post->url);
|
||||
$token = trim($this->post->token);
|
||||
|
||||
$user = $this->gitlab->apiGetCurrentUser($this->post->url, $this->post->token);
|
||||
if(strpos($gitlabURL, 'http') !== 0) return $this->send(array('result' => 'fail', 'message' => array('url' => array($this->lang->gitlab->hostError))));
|
||||
if(!$token) return $this->send(array('result' => 'fail', 'message' => array('token' => array($this->lang->gitlab->tokenError))));
|
||||
|
||||
$user = $this->gitlab->apiGetCurrentUser($gitlabURL, $token);
|
||||
|
||||
if(!is_object($user)) return $this->send(array('result' => 'fail', 'message' => array('url' => array($this->lang->gitlab->hostError))));
|
||||
if(!isset($user->is_admin) or !$user->is_admin) return $this->send(array('result' => 'fail', 'message' => array('token' => array($this->lang->gitlab->tokenError))));
|
||||
@@ -256,6 +259,11 @@ class gitlab extends control
|
||||
$gitlabID = $repo->gitlab;
|
||||
$projectID = $repo->project;
|
||||
|
||||
$gitlab = $this->gitlab->getByID($gitlabID);
|
||||
$user = $this->gitlab->apiGetCurrentUser($gitlab->url, $gitlab->token);
|
||||
if(!isset($user->is_admin) or !$user->is_admin) die(js::alert($this->lang->gitlab->tokenLimit) . js::locate($this->createLink('gitlab', 'edit', array('gitlabID' => $gitlabID))));
|
||||
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
$executionList = $this->post->executionList;
|
||||
|
||||
@@ -40,6 +40,7 @@ $lang->gitlab->placeholder->token = "Please fill in the access token of an accou
|
||||
|
||||
$lang->gitlab->noImportableIssues = "There are currently no issues available for import.";
|
||||
$lang->gitlab->tokenError = "The current token is not admin rights.";
|
||||
$lang->gitlab->tokenLimit = "The current token has no admin privilege. Please regenerate one with admin user in GitLab.";
|
||||
$lang->gitlab->hostError = "Invalid GitLab service address.";
|
||||
$lang->gitlab->bindUserError = "Can not bind users repeatedly %s";
|
||||
$lang->gitlab->importIssueError = "The execution to which this issue belongs is not selected.";
|
||||
|
||||
@@ -76,6 +76,7 @@ class pipelineModel extends model
|
||||
->add('private',md5(rand(10,113450)))
|
||||
->add('createdBy', $this->app->user->account)
|
||||
->add('createdDate', helper::now())
|
||||
->trim('token')
|
||||
->skipSpecial('url,token,account,password')
|
||||
->get();
|
||||
if($type == 'gitlab') $pipeline->url = rtrim($pipeline->url, '/');
|
||||
@@ -104,6 +105,7 @@ class pipelineModel extends model
|
||||
$pipeline = fixer::input('post')
|
||||
->add('editedBy', $this->app->user->account)
|
||||
->add('editedDate', helper::now())
|
||||
->trim('token')
|
||||
->skipSpecial('url,token,account,password')
|
||||
->get();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user