34 lines
915 B
PHP
34 lines
915 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('Your user account no longer exists.');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function checkPostAuth(UserInterface $user): void
|
||
|
{
|
||
|
if (!$user instanceof User) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (!$user->isIsactive()) {
|
||
|
throw new AccountExpiredException('...');
|
||
|
}
|
||
|
}
|
||
|
}
|