1
0

IVerificationToken.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Security\VerificationToken;
  8. use OCP\IUser;
  9. /**
  10. * @since 23.0.0
  11. */
  12. interface IVerificationToken {
  13. /**
  14. * Checks whether the a provided tokent matches a stored token and its
  15. * constraints. An InvalidTokenException is thrown on issues, otherwise
  16. * the check is successful.
  17. *
  18. * null can be passed as $user, but mind that this is for conveniently
  19. * passing the return of IUserManager::getUser() to this method. When
  20. * $user is null, InvalidTokenException is thrown for all the issued
  21. * tokens are user related.
  22. *
  23. * @throws InvalidTokenException
  24. * @since 23.0.0
  25. */
  26. public function check(string $token, ?IUser $user, string $subject, string $passwordPrefix = '', bool $expiresWithLogin = false): void;
  27. /**
  28. * @since 23.0.0
  29. */
  30. public function create(IUser $user, string $subject, string $passwordPrefix = ''): string;
  31. /**
  32. * Deletes the token identified by the provided parameters
  33. *
  34. * @since 23.0.0
  35. */
  36. public function delete(string $token, IUser $user, string $subject): void;
  37. }