2022-09-29 16:53:21 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Service;
|
|
|
|
|
|
|
|
use App\Entity\User;
|
|
|
|
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
|
|
|
|
use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;
|
|
|
|
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
|
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
|
|
|
|
|
|
|
class UserChecker implements UserCheckerInterface
|
|
|
|
{
|
|
|
|
public function checkPreAuth(UserInterface $user): void
|
|
|
|
{
|
|
|
|
if (!$user instanceof User) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$user->isIsactive()) {
|
2022-10-02 14:50:48 +02:00
|
|
|
throw new CustomUserMessageAccountStatusException('Votre compte a été désactivé');
|
2022-09-29 16:53:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function checkPostAuth(UserInterface $user): void
|
|
|
|
{
|
|
|
|
if (!$user instanceof User) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$user->isIsactive()) {
|
|
|
|
throw new AccountExpiredException('...');
|
|
|
|
}
|
|
|
|
}
|
2022-10-02 14:50:48 +02:00
|
|
|
}
|