AdvancedUserInterface.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Security\Core\User;
  11. use Symfony\Component\Security\Core\Exception\AccountExpiredException;
  12. use Symfony\Component\Security\Core\Exception\AccountStatusException;
  13. use Symfony\Component\Security\Core\Exception\CredentialsExpiredException;
  14. use Symfony\Component\Security\Core\Exception\DisabledException;
  15. use Symfony\Component\Security\Core\Exception\LockedException;
  16. /**
  17. * Adds extra features to a user class related to account status flags.
  18. *
  19. * This interface can be implemented in place of UserInterface if you'd like
  20. * the authentication system to consider different account status flags
  21. * during authentication. If any of the methods in this interface return
  22. * false, authentication will fail.
  23. *
  24. * If you need to perform custom logic for any of these situations, then
  25. * you will need to register an exception listener and watch for the specific
  26. * exception instances thrown in each case. All exceptions are a subclass
  27. * of AccountStatusException
  28. *
  29. * @see UserInterface
  30. * @see AccountStatusException
  31. *
  32. * @author Fabien Potencier <fabien@symfony.com>
  33. */
  34. interface AdvancedUserInterface extends UserInterface
  35. {
  36. /**
  37. * Checks whether the user's account has expired.
  38. *
  39. * Internally, if this method returns false, the authentication system
  40. * will throw an AccountExpiredException and prevent login.
  41. *
  42. * @return bool true if the user's account is non expired, false otherwise
  43. *
  44. * @see AccountExpiredException
  45. */
  46. public function isAccountNonExpired();
  47. /**
  48. * Checks whether the user is locked.
  49. *
  50. * Internally, if this method returns false, the authentication system
  51. * will throw a LockedException and prevent login.
  52. *
  53. * @return bool true if the user is not locked, false otherwise
  54. *
  55. * @see LockedException
  56. */
  57. public function isAccountNonLocked();
  58. /**
  59. * Checks whether the user's credentials (password) has expired.
  60. *
  61. * Internally, if this method returns false, the authentication system
  62. * will throw a CredentialsExpiredException and prevent login.
  63. *
  64. * @return bool true if the user's credentials are non expired, false otherwise
  65. *
  66. * @see CredentialsExpiredException
  67. */
  68. public function isCredentialsNonExpired();
  69. /**
  70. * Checks whether the user is enabled.
  71. *
  72. * Internally, if this method returns false, the authentication system
  73. * will throw a DisabledException and prevent login.
  74. *
  75. * @return bool true if the user is enabled, false otherwise
  76. *
  77. * @see DisabledException
  78. */
  79. public function isEnabled();
  80. }