]> Raphaƫl G. Git Repositories - userbundle/blobdiff - Checker/UserChecker.php
Replace hardcoded role by configurable key
[userbundle] / Checker / UserChecker.php
index 1240c8a1cdce59f0e495f1b41f4915ab7c5942e5..dc1e531046993e3bfad695122aa0dc612b782b5b 100644 (file)
 
 namespace Rapsys\UserBundle\Checker;
 
 
 namespace Rapsys\UserBundle\Checker;
 
-use Symfony\Component\Security\Core\User\UserChecker as BaseUserChecker;
-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\User\InMemoryUserChecker;
+use Symfony\Component\Security\Core\Exception\DisabledException;
+use Symfony\Component\Security\Core\User\UserInterface;
+
 /**
  * {@inheritdoc}
  */
 /**
  * {@inheritdoc}
  */
-class UserChecker extends BaseUserChecker {
+class UserChecker extends InMemoryUserChecker {
        /**
         * {@inheritdoc}
         */
        /**
         * {@inheritdoc}
         */
@@ -32,17 +32,20 @@ class UserChecker extends BaseUserChecker {
                }
 
                //With not activated user
                }
 
                //With not activated user
-        if (!$user->isActivated()) {
-            $ex = new UnactivatedException('Account is not activated');
-            $ex->setUser($user);
-            throw $ex;
-        }
-
-               //With disabled user
-        if ($user->isDisabled()) {
-            $ex = new DisabledException('Account is disabled');
-            $ex->setUser($user);
-            throw $ex;
-        }
+               if (!$user->isActivated()) {
+                       $ex = new UnactivatedException('User Account is not activated');
+                       $ex->setUser($user);
+                       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);
        }
 }
        }
 }