Commit 684d02e7 authored by Daniel Pfeiffer's avatar Daniel Pfeiffer Committed by Paulo Henrique Cota Starling
Browse files

Issue #3312100 by mediabounds, gabrieldv: Improved compatibility with simple_pass_reset

parent 45f9bf64
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ services:
      - '@config.factory'
      - '@current_user'
      - '@entity_type.manager'
      - '@current_route_match'

  password_policy_event_subscriber:
      class: Drupal\password_policy\EventSubscriber\PasswordPolicyEventSubscriber
+14 −3
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Drupal\password_policy;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountProxyInterface;

/**
@@ -36,6 +37,13 @@ class PasswordPolicyValidationManager implements PasswordPolicyValidationManager
   */
  protected $userSettingsConfig;

  /**
   * Current route match.
   *
   * @var \Drupal\Core\Routing\RouteMatchInterface
   */
  protected $routeMatch;

  /**
   * PasswordPolicyVisibilityManager constructor.
   *
@@ -45,21 +53,24 @@ class PasswordPolicyValidationManager implements PasswordPolicyValidationManager
   *   The current logged in user.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   The entity type manager.
   * @param \Drupal\Core\Routing\RouteMatchInterface $routeMatch
   *   The current route match.
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
   * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
   */
  public function __construct(ConfigFactoryInterface $configFactory, AccountProxyInterface $currentUser, EntityTypeManagerInterface $entityTypeManager) {
  public function __construct(ConfigFactoryInterface $configFactory, AccountProxyInterface $currentUser, EntityTypeManagerInterface $entityTypeManager, RouteMatchInterface $routeMatch) {
    $this->currentUser = $currentUser;
    $this->passwordPolicyStorage = $entityTypeManager->getStorage('password_policy');
    $this->userSettingsConfig = $configFactory->get('user.settings');
    $this->routeMatch = $routeMatch;
  }

  /**
   * {@inheritdoc}
   */
  public function tableShouldBeVisible() {
    if ($this->currentUser->isAnonymous() && $this->userSettingsConfig->get('verify_mail')) {
    if ($this->currentUser->isAnonymous() && $this->userSettingsConfig->get('verify_mail') && $this->routeMatch->getRouteName() !== 'user.reset') {
      return FALSE;
    }

@@ -74,7 +85,7 @@ class PasswordPolicyValidationManager implements PasswordPolicyValidationManager
   * {@inheritdoc}
   */
  public function validationShouldRun() {
    if ($this->currentUser->isAnonymous() && $this->userSettingsConfig->get('verify_mail')) {
    if ($this->currentUser->isAnonymous() && $this->userSettingsConfig->get('verify_mail') && $this->routeMatch->getRouteName() !== 'user.reset') {
      return FALSE;
    }