* Finish task 38937.

This commit is contained in:
Guanxiying
2021-06-08 16:53:22 +08:00
parent e09060e7ca
commit b9584dc3c2
7 changed files with 24 additions and 39 deletions
+7 -4
View File
@@ -80,10 +80,13 @@ class gitlabModel extends model
*/
public function getPermissionsByToken($host, $token)
{
$host = rtrim($host, '/');
$host .= '/api/v4/activities';
$results = json_decode(file_get_contents($host . "?private_token=$token"));
if(strpos($host, 'http') !== 0) return array('result' => 'fail', 'message' => array('url' => array($this->lang->gitlab->hostError)));
if(!$this->post->token) return array('result' => 'fail', 'message' => array('token' => array($this->lang->gitlab->tokenError)));
$host = rtrim($host, '/') . "/api/v4/user?private_token=$token";
$response = json_decode(commonModel::http($host));
return $results;
if(!is_object($response)) return array('result' => 'fail', 'message' => array('url' => array($this->lang->gitlab->hostError)));
if(isset($response->is_admin) and $response->is_admin == true) return array('result' => 'success');
return array('result' => 'fail', 'message' => array('token' => array($this->lang->gitlab->tokenError)));
}
}