private function LoginHandler::checkUserExists in Shibboleth Authentication 8
Check shib_authmap table for user, return true if user found.
Return value
bool
Throws
\Exception
1 call to LoginHandler::checkUserExists()
- LoginHandler::shibLogin in src/
Login/ LoginHandler.php
File
- src/
Login/ LoginHandler.php, line 283
Class
- LoginHandler
- Class LoginHandler.
Namespace
Drupal\shib_auth\LoginCode
private function checkUserExists() {
$user_query = $this->db
->select('shib_authmap');
$user_query
->fields('shib_authmap', [
'id',
'uid',
'targeted_id',
]);
$user_query
->condition('targeted_id', $this->shib_session
->getTargetedId());
$results = $user_query
->execute()
->fetchAll();
if (empty($results)) {
// No user found.
return FALSE;
}
if (count($results) > 1) {
$this
->setErrorMessage(t('There was an error logging you in.'));
throw new \Exception('Multiple entries for a user exist in the shib_authmap table.');
}
$this->user = User::load($results[0]->uid);
if (empty($this->user)) {
$this
->setErrorMessage(t('There was an error logging you in.'));
throw new \Exception('User information exists in shib_authmap table, but Drupal user does not exist.');
}
return TRUE;
}