Skip to content

Commit

Permalink
CRM-21526: CRM_Utils_System_Drupal8::authenticate() should change the…
Browse files Browse the repository at this point in the history
… current Drupal user
  • Loading branch information
dsnopek authored and sluc23 committed Jan 10, 2018
1 parent 69dd7ca commit 0260ae7
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 0260ae7

Please sign in to comment.