]> Raphaƫl G. Git Repositories - userbundle/blobdiff - Checker/UserChecker.php
Version 0.5.8
[userbundle] / Checker / UserChecker.php
index 744a35e37403228eb6a87b6030b93e346ffd0a09..51b6fa98d7734a37c0811ccda899d9a555764047 100644 (file)
 
 namespace Rapsys\UserBundle\Checker;
 
 
 namespace Rapsys\UserBundle\Checker;
 
-use Symfony\Component\Security\Core\User\InMemoryUserChecker;
-use Symfony\Component\Security\Core\Exception\DisabledException;
-use Symfony\Component\Security\Core\User\UserInterface;
-
 use Rapsys\UserBundle\Entity\User;
 use Rapsys\UserBundle\Exception\UnactivatedException;
 
 use Rapsys\UserBundle\Entity\User;
 use Rapsys\UserBundle\Exception\UnactivatedException;
 
+use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+use Symfony\Component\Security\Core\Exception\DisabledException;
+use Symfony\Component\Security\Core\User\InMemoryUserChecker;
+use Symfony\Component\Security\Core\User\UserInterface;
+
 /**
  * {@inheritdoc}
  */
 /**
  * {@inheritdoc}
  */
@@ -25,7 +26,7 @@ class UserChecker extends InMemoryUserChecker {
        /**
         * {@inheritdoc}
         */
        /**
         * {@inheritdoc}
         */
-       public function checkPostAuth(UserInterface $user): void {
+       public function checkPostAuth(UserInterface $user, ?TokenInterface $token = null): void {
                //Without User instance
                if (!$user instanceof User) {
                        return;
                //Without User instance
                if (!$user instanceof User) {
                        return;
@@ -38,6 +39,13 @@ class UserChecker extends InMemoryUserChecker {
                        throw $ex;
                }
 
                        throw $ex;
                }
 
+               //With not enabled user
+               if (!$user->isEnabled()) {
+                       $ex = new DisabledException('User account is not enabled');
+                       $ex->setUser($user);
+                       throw $ex;
+               }
+
                //Call parent checkPreAuth
                parent::checkPostAuth($user);
        }
                //Call parent checkPreAuth
                parent::checkPostAuth($user);
        }