Commit 0f9e1b9b authored by Daniel Pfeiffer's avatar Daniel Pfeiffer Committed by Paulo Henrique Cota Starling
Browse files

Issue #3314234 by mediabounds, gabrieldv, jfurnas: Password history policy...

Issue #3314234 by mediabounds, gabrieldv, jfurnas: Password history policy shows confusing error message when history_repeats is set to 0
parent 684d02e7
Loading
Loading
Loading
Loading
+3 −1
Changes for password_policy_history/src/Plugin/PasswordConstraint/PasswordHistory.php: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -87,11 +87,13 @@ class PasswordHistory extends PasswordConstraintBase implements ContainerFactory
      if ($this->getPasswordService()->check($password, $hash->pass_hash)) {
        $configuration = $this->getConfiguration();
        if ($configuration['history_repeats'] == 0) {
          $validation->setErrorMessage($this->t('No one of the old passwords can be reused. Choose a different password'));
          $validation->setErrorMessage($this->t('Previous passwords cannot be reused. Choose a different password.'));
        }
        else {
          $validation->setErrorMessage($this->formatPlural($configuration['history_repeats'], 'The last @count password cannot be reused. Choose a different password.', 'The last @count passwords cannot be reused. Choose a different password.', ['@count' => $configuration['history_repeats']]));
        }
      }
    }

    return $validation;
  }