UserChecker.php 878 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Security;
  3. use App\Entity\User as AppUser;
  4. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  5. use Symfony\Component\Security\Core\Exception\AccountExpiredException;
  6. use Symfony\Component\Security\Core\User\UserCheckerInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. class UserChecker implements UserCheckerInterface
  9. {
  10. public function checkPreAuth(UserInterface $user): void
  11. {
  12. if (!$user instanceof AppUser)
  13. {
  14. return;
  15. }
  16. }
  17. public function checkPostAuth(UserInterface $user, ?TokenInterface $token = null): void
  18. {
  19. if (!$user instanceof AppUser)
  20. {
  21. return;
  22. }
  23. if (!$user->isEnabled())
  24. {
  25. //dump($user);
  26. throw new AccountExpiredException("Ce compte n'a pas été activé");
  27. }
  28. }
  29. }