Merge branch 'devops_caoyanyi' into 'devops20'
* Modify root token check. See merge request easycorp/zentaopms!1608
This commit is contained in:
@@ -248,7 +248,7 @@ class gitlab extends control
|
||||
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);
|
||||
$user = $this->gitlab->apiGetCurrentUser($gitlabURL, $token, true);
|
||||
|
||||
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))));
|
||||
|
||||
@@ -79,12 +79,12 @@ $lang->gitlab->noAccess = 'Permission denied';
|
||||
$lang->gitlab->placeholder = new stdclass;
|
||||
$lang->gitlab->placeholder->name = '';
|
||||
$lang->gitlab->placeholder->url = "Please fill in the access address of the GitLab Server homepage, as: https://gitlab.zentao.net.";
|
||||
$lang->gitlab->placeholder->token = "Please fill in the access token of an account with admin privileges.";
|
||||
$lang->gitlab->placeholder->token = "Please fill in the access token of an account with root privileges.";
|
||||
$lang->gitlab->placeholder->projectPath = "It should contain only letters, digits, underscore, hyphen and period. It should not start with hypen, or end with .git or .atom.";
|
||||
|
||||
$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->tokenError = "The current token is not root rights.";
|
||||
$lang->gitlab->tokenLimit = "The current token has no admin privilege. Please regenerate one with root 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.";
|
||||
|
||||
@@ -79,12 +79,12 @@ $lang->gitlab->noAccess = '权限不足';
|
||||
$lang->gitlab->placeholder = new stdclass;
|
||||
$lang->gitlab->placeholder->name = '';
|
||||
$lang->gitlab->placeholder->url = "请填写GitLab Server首页的访问地址,如:https://gitlab.zentao.net。";
|
||||
$lang->gitlab->placeholder->token = "请填写具有admin权限账户的access token";
|
||||
$lang->gitlab->placeholder->token = "请填写具有root权限账户的access token";
|
||||
$lang->gitlab->placeholder->projectPath = "项目标识串只能包含字母、数字、“_”、“-”和“.”。不能以“-”开头,以.git或者.atom结尾";
|
||||
|
||||
$lang->gitlab->noImportableIssues = "目前没有可供导入的issue。";
|
||||
$lang->gitlab->tokenError = "当前token非管理员权限。";
|
||||
$lang->gitlab->tokenLimit = "GitLab Token权限不足。请更换为有管理员权限的GitLab Token。";
|
||||
$lang->gitlab->tokenError = "当前token非root权限。";
|
||||
$lang->gitlab->tokenLimit = "GitLab Token权限不足。请更换为有root权限的GitLab Token。";
|
||||
$lang->gitlab->hostError = "无效的GitLab服务地址。";
|
||||
$lang->gitlab->bindUserError = "不能重复绑定用户 %s";
|
||||
$lang->gitlab->importIssueError = "未选择该issue所属的执行。";
|
||||
|
||||
@@ -468,12 +468,14 @@ class gitlabModel extends model
|
||||
*
|
||||
* @param string $host
|
||||
* @param string $token
|
||||
* @param bool $rootCheck
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function apiGetCurrentUser($host, $token)
|
||||
public function apiGetCurrentUser($host, $token, $rootCheck = false)
|
||||
{
|
||||
$host = rtrim($host, '/') . "/api/v4%s?private_token=$token";
|
||||
if($rootCheck) $host .= '&sudo=1';
|
||||
return $this->apiGet($host, '/user');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user