From 49d823e99f9815fca231b76aceef894531e7b42c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Wed, 29 Nov 2023 16:21:48 +0100 Subject: [PATCH] Adapt entity and user checker to match with symfony classes and interfaces --- Checker/UserChecker.php | 18 +++++++----------- Entity/User.php | 14 +++++--------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/Checker/UserChecker.php b/Checker/UserChecker.php index e34284e..744a35e 100644 --- a/Checker/UserChecker.php +++ b/Checker/UserChecker.php @@ -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); } } diff --git a/Entity/User.php b/Entity/User.php index 4eee930..809d363 100644 --- a/Entity/User.php +++ b/Entity/User.php @@ -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; } /** -- 2.41.0