Loading password_policy.services.yml +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading src/PasswordPolicyValidationManager.php +14 −3 Original line number Diff line number Diff line Loading @@ -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; /** Loading Loading @@ -36,6 +37,13 @@ class PasswordPolicyValidationManager implements PasswordPolicyValidationManager */ protected $userSettingsConfig; /** * Current route match. * * @var \Drupal\Core\Routing\RouteMatchInterface */ protected $routeMatch; /** * PasswordPolicyVisibilityManager constructor. * Loading @@ -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; } Loading @@ -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; } Loading Loading
password_policy.services.yml +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
src/PasswordPolicyValidationManager.php +14 −3 Original line number Diff line number Diff line Loading @@ -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; /** Loading Loading @@ -36,6 +37,13 @@ class PasswordPolicyValidationManager implements PasswordPolicyValidationManager */ protected $userSettingsConfig; /** * Current route match. * * @var \Drupal\Core\Routing\RouteMatchInterface */ protected $routeMatch; /** * PasswordPolicyVisibilityManager constructor. * Loading @@ -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; } Loading @@ -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; } Loading