Skip to content

Commit

Permalink
Merge pull request civicrm#11381 from mydropwizard/crm-21526
Browse files Browse the repository at this point in the history
CRM-21526: CRM_Utils_System_Drupal8::authenticate() should change the Drupal user
  • Loading branch information
jackrabbithanna authored and sluc23 committed Jan 10, 2018
2 parents 8dc3fb6 + 0260ae7 commit 73f86ce
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions CRM/Utils/System/Drupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,14 @@ public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realP
$system->loadBootStrap(array(), FALSE);

$uid = \Drupal::service('user.auth')->authenticate($name, $password);
$contact_id = CRM_Core_BAO_UFMatch::getContactId($uid);
if ($uid) {
if ($this->loadUser($name)) {
$contact_id = CRM_Core_BAO_UFMatch::getContactId($uid);
return array($contact_id, $uid, mt_rand());
}
}

return array($contact_id, $uid, mt_rand());
return FALSE;
}

/**
Expand Down Expand Up @@ -469,7 +474,7 @@ public function loadBootStrap($params = array(), $loadUser = TRUE, $throwError =
if (!empty($params['uid']) && $username = \Drupal\user\Entity\User::load($uid)->getUsername()) {
$this->loadUser($username);
}
elseif (!empty($params['name']) && !empty($params['pass']) && $this->authenticate($params['name'], $params['pass'])) {
elseif (!empty($params['name']) && !empty($params['pass']) && \Drupal::service('user.auth')->authenticate($params['name'], $params['pass'])) {
$this->loadUser($params['name']);
}
}
Expand Down

0 comments on commit 73f86ce

Please sign in to comment.