UserChecker.php 760 B

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