35 lines
913 B
PHP
35 lines
913 B
PHP
<?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()) {
|
|
throw new CustomUserMessageAccountStatusException('Votre compte a été désactivé');
|
|
}
|
|
}
|
|
|
|
public function checkPostAuth(UserInterface $user): void
|
|
{
|
|
if (!$user instanceof User) {
|
|
return;
|
|
}
|
|
|
|
if (!$user->isIsactive()) {
|
|
throw new AccountExpiredException('...');
|
|
}
|
|
}
|
|
}
|