From c0c5132a12b40bef4ed4649cac54b466772860f6 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Wed, 6 Dec 2017 09:53:42 -0600 Subject: [PATCH] CRM-21526: CRM_Utils_System_Drupal8::authenticate() should change the current Drupal user --- CRM/Utils/System/Drupal8.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index 09f102b75a..be2bb03a6f 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -365,9 +365,14 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { $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; } /** @@ -469,7 +474,7 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { 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']); } } -- 2.25.1