* Fix bind gitlab user function.

This commit is contained in:
Guan Xiying
2021-06-17 14:27:23 +08:00
parent 2c97d3cc2d
commit 1969d12f2f
4 changed files with 47 additions and 53 deletions
+12 -15
View File
@@ -123,7 +123,7 @@ class gitlabModel extends model
* @access public
* @return array
*/
public function getMatchedUsers($gitlabUsers, $zentaoUsers)
public function getMatchedUsers($gitlabID, $gitlabUsers, $zentaoUsers)
{
$matches = new stdclass;
foreach($gitlabUsers as $gitlabUser)
@@ -136,11 +136,21 @@ class gitlabModel extends model
}
}
/*Get binded users from db.*/
$bindedUsers = $this->dao->select('openID,account')->from(TABLE_OAUTH)
->where('providerType')->eq('gitlab')
->andWhere('providerID')->eq($gitlabID)
->fetchPairs();
$matchedUsers = array();
foreach($gitlabUsers as $gitlabUser)
{
if(isset($bindedUsers[$gitlabUser->id]))
{
$gitlabUser->zentaoAccount = $bindedUsers[$gitlabUser->id];
$matchedUsers[] = $gitlabUser;
continue;
}
$matchedZentaoUsers = array();
if(isset($matches->accounts[$gitlabUser->account])) $matchedZentaoUsers = array_merge($matchedZentaoUsers, $matches->accounts[$gitlabUser->account]);
if(isset($matches->emails[$gitlabUser->email])) $matchedZentaoUsers = array_merge($matchedZentaoUsers, $matches->emails[$gitlabUser->email]);
@@ -196,19 +206,6 @@ class gitlabModel extends model
return $gitlab_url;
}
/**
* check if gitlab id exists
*
* @param string
* @access public
* @return array
*/
public function checkAccountId($openID,$providerID)
{
return $this->dao->select('openID')->from(TABLE_OAUTH)->where('openID')->eq($openID)->andWhere('providerID')->eq($providerID)->fetch('openID');
}
/**
* Get hooks.
*