* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ 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; /** * {@inheritdoc} */ class UserChecker extends BaseUserChecker { /** * {@inheritdoc} */ public function checkPostAuth(UserInterface $user): void { //Without User instance if (!$user instanceof User) { return; } //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; } } }