]> Raphaël G. Git Repositories - userbundle/commitdiff
Adapt entity and user checker to match with symfony classes and interfaces
authorRaphaël Gertz <git@rapsys.eu>
Wed, 29 Nov 2023 15:21:48 +0000 (16:21 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Wed, 29 Nov 2023 15:21:48 +0000 (16:21 +0100)
Checker/UserChecker.php
Entity/User.php

index e34284e92e0cd94a0b0c4c6416e442fda865c920..744a35e37403228eb6a87b6030b93e346ffd0a09 100644 (file)
@@ -32,17 +32,13 @@ class UserChecker extends InMemoryUserChecker {
                }
 
                //With not activated user
-        if (!$user->isActivated()) {
-            $ex = new UnactivatedException('Account is not activated');
-            $ex->setUser($user);
-            throw $ex;
-        }
+               if (!$user->isActivated()) {
+                       $ex = new UnactivatedException('User 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;
-        }
+               //Call parent checkPreAuth
+               parent::checkPostAuth($user);
        }
 }
index 4eee930541e5f2c6bf29ca2e9e5891b2cea0d5b3..809d363777ea36555d855b7ca991318de32b5a65 100644 (file)
@@ -454,23 +454,19 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface {
        /**
         * Check if account is activated
         *
-        * It was from deprecated AdvancedUserInterface, see if it's used anymore
-        *
-        * @see vendor/symfony/security-core/User/AdvancedUserInterface.php
+        * @see vendor/rapsys/userbundle/Checker/UserChecker.php
         */
        public function isActivated(): bool {
                return $this->active;
        }
 
        /**
-        * Check if account is disabled
-        *
-        * It was from deprecated AdvancedUserInterface, see if it's used anymore
+        * Check if account is enabled
         *
-        * @see vendor/symfony/security-core/User/AdvancedUserInterface.php
+        * @see vendor/symfony/security-core/User/InMemoryUserChecker.php
         */
-       public function isDisabled(): bool {
-               return $this->disabled;
+       public function isEnabled(): bool {
+               return !$this->disabled;
        }
 
        /**