1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys UserBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\UserBundle\Checker
;
14 use Rapsys\UserBundle\Entity\User
;
15 use Rapsys\UserBundle\Exception\UnactivatedException
;
17 use Symfony\Component\Security\Core\Authentication\Token\TokenInterface
;
18 use Symfony\Component\Security\Core\Exception\DisabledException
;
19 use Symfony\Component\Security\Core\User\InMemoryUserChecker
;
20 use Symfony\Component\Security\Core\User\UserInterface
;
25 class UserChecker
extends InMemoryUserChecker
{
29 public function checkPostAuth(UserInterface
$user, ?TokenInterface
$token = null): void {
30 //Without User instance
31 if (!$user instanceof User
) {
35 //With not activated user
36 if (!$user->isActivated()) {
37 $ex = new UnactivatedException('User Account is not activated');
42 //With not enabled user
43 if (!$user->isEnabled()) {
44 $ex = new DisabledException('User account is not enabled');
49 //Call parent checkPreAuth
50 parent
::checkPostAuth($user);