This commit is contained in:
Gnieark 2019-12-30 15:10:51 +01:00
parent 375cbbc281
commit 12ac1aba25
2 changed files with 39 additions and 0 deletions

View File

@ -14,8 +14,11 @@ security:
dev: dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/ pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false security: false
main: main:
anonymous: ~ anonymous: ~
pattern: ^/
user_checker: App\Security\UserChecker
guard: guard:
authenticators: authenticators:
- App\Security\LoginFormAuthentificatorAuthenticator - App\Security\LoginFormAuthentificatorAuthenticator

View File

@ -0,0 +1,36 @@
<?php
namespace App\Security;
use App\Exception\AccountDeletedException;
use App\Security\User as AppUser;
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
use Symfony\Component\Security\Core\User\UserCheckerInterface;
use Symfony\Component\Security\Core\User\UserInterface;
class UserChecker implements UserCheckerInterface
{
public function checkPreAuth(UserInterface $user)
{
if (!$user instanceof AppUser) {
return;
}
// user is not activated
if ($user-> getActive() === false) {
throw new AccountDeletedException();
}
}
public function checkPostAuth(UserInterface $user)
{
if (!$user instanceof AppUser) {
return;
}
// user is not activated
if ($user->getActive() === false) {
throw new AccountDeletedException();
}
}
}