ValidatePasswordPolicyEvent.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Security\Events;
  8. use OCP\EventDispatcher\Event;
  9. use OCP\Security\PasswordContext;
  10. /**
  11. * This event can be emitted to request a validation of a password.
  12. *
  13. * If a password policy app is installed and the password
  14. * is invalid, an `\OCP\HintException` will be thrown.
  15. * @since 18.0.0
  16. */
  17. class ValidatePasswordPolicyEvent extends Event {
  18. /**
  19. * @since 18.0.0
  20. * @since 31.0.0 - $context parameter added
  21. */
  22. public function __construct(
  23. private string $password,
  24. private PasswordContext $context = PasswordContext::ACCOUNT,
  25. ) {
  26. parent::__construct();
  27. }
  28. /**
  29. * Get the password that should be validated.
  30. * @since 18.0.0
  31. */
  32. public function getPassword(): string {
  33. return $this->password;
  34. }
  35. /**
  36. * Get the context this password should validated for.
  37. * @since 31.0.0
  38. */
  39. public function getContext(): PasswordContext {
  40. return $this->context;
  41. }
  42. }