Loading openid_connect.services.yml +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ services: openid_connect.authmap: class: Drupal\openid_connect\Authmap arguments: ["@database"] arguments: ["@database", "@entity_type.manager"] openid_connect.claims: class: Drupal\openid_connect\Claims Loading src/Authmap.php +16 −5 Original line number Diff line number Diff line Loading @@ -3,10 +3,10 @@ namespace Drupal\openid_connect; use Drupal\Core\Database\Connection; use Drupal\user\Entity\User; use Drupal\Core\Entity\EntityTypeManagerInterface; /** * Class Authmap. * The OpenID Connect authmap service. * * @package Drupal\openid_connect */ Loading @@ -20,13 +20,23 @@ class Authmap { protected $connection; /** * Constructs a Authmap object. * The User entity storage. * * @var \Drupal\Core\Entity\EntityStorageInterface */ protected $userStorage; /** * Constructs a OpenIDConnectAuthmap service object. * * @param \Drupal\Core\Database\Connection $connection * A database connection. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity manager. */ public function __construct(Connection $connection) { public function __construct(Connection $connection, EntityTypeManagerInterface $entity_type_manager) { $this->connection = $connection; $this->userStorage = $entity_type_manager->getStorage('user'); } /** Loading Loading @@ -85,7 +95,8 @@ class Authmap { ->condition('sub', $sub, '=') ->execute(); foreach ($result as $record) { $account = User::load($record->uid); /* @var \Drupal\user\Entity\User $account */ $account = $this->userStorage->load($record->uid); if (is_object($account)) { return $account; } Loading src/Controller/RedirectController.php +5 −6 Original line number Diff line number Diff line Loading @@ -59,7 +59,6 @@ class RedirectController extends ControllerBase implements AccessInterface { LoggerChannelFactoryInterface $logger_factory, AccountInterface $current_user ) { $this->pluginManager = $plugin_manager; $this->requestStack = $request_stack; $this->loggerFactory = $logger_factory; Loading Loading @@ -169,7 +168,7 @@ class RedirectController extends ControllerBase implements AccessInterface { if ($parameters['op'] === 'login') { $success = openid_connect_complete_authorization($client, $tokens, $destination); $register = \Drupal::config('user.settings')->get('register'); $register = $this->config('user.settings')->get('register'); if (!$success && $register !== USER_REGISTER_ADMINISTRATORS_ONLY) { drupal_set_message(t('Logging in with @provider could not be completed due to an error.', $provider_param), 'error'); } Loading Loading
openid_connect.services.yml +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ services: openid_connect.authmap: class: Drupal\openid_connect\Authmap arguments: ["@database"] arguments: ["@database", "@entity_type.manager"] openid_connect.claims: class: Drupal\openid_connect\Claims Loading
src/Authmap.php +16 −5 Original line number Diff line number Diff line Loading @@ -3,10 +3,10 @@ namespace Drupal\openid_connect; use Drupal\Core\Database\Connection; use Drupal\user\Entity\User; use Drupal\Core\Entity\EntityTypeManagerInterface; /** * Class Authmap. * The OpenID Connect authmap service. * * @package Drupal\openid_connect */ Loading @@ -20,13 +20,23 @@ class Authmap { protected $connection; /** * Constructs a Authmap object. * The User entity storage. * * @var \Drupal\Core\Entity\EntityStorageInterface */ protected $userStorage; /** * Constructs a OpenIDConnectAuthmap service object. * * @param \Drupal\Core\Database\Connection $connection * A database connection. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity manager. */ public function __construct(Connection $connection) { public function __construct(Connection $connection, EntityTypeManagerInterface $entity_type_manager) { $this->connection = $connection; $this->userStorage = $entity_type_manager->getStorage('user'); } /** Loading Loading @@ -85,7 +95,8 @@ class Authmap { ->condition('sub', $sub, '=') ->execute(); foreach ($result as $record) { $account = User::load($record->uid); /* @var \Drupal\user\Entity\User $account */ $account = $this->userStorage->load($record->uid); if (is_object($account)) { return $account; } Loading
src/Controller/RedirectController.php +5 −6 Original line number Diff line number Diff line Loading @@ -59,7 +59,6 @@ class RedirectController extends ControllerBase implements AccessInterface { LoggerChannelFactoryInterface $logger_factory, AccountInterface $current_user ) { $this->pluginManager = $plugin_manager; $this->requestStack = $request_stack; $this->loggerFactory = $logger_factory; Loading Loading @@ -169,7 +168,7 @@ class RedirectController extends ControllerBase implements AccessInterface { if ($parameters['op'] === 'login') { $success = openid_connect_complete_authorization($client, $tokens, $destination); $register = \Drupal::config('user.settings')->get('register'); $register = $this->config('user.settings')->get('register'); if (!$success && $register !== USER_REGISTER_ADMINISTRATORS_ONLY) { drupal_set_message(t('Logging in with @provider could not be completed due to an error.', $provider_param), 'error'); } Loading