added UserNotVerifiedException
This commit is contained in:
parent
2184fd001d
commit
e7031c5e63
@ -2,28 +2,21 @@
|
||||
|
||||
namespace App\Security;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Form\LoginFormType;
|
||||
use App\Exception\UserNotVerifiedException;
|
||||
use App\Repository\UserRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\CustomCredentials;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
|
||||
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
||||
use Symfony\Component\Security\Http\Util\TargetPathTrait;
|
||||
|
||||
/**
|
||||
@ -41,7 +34,7 @@ class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
|
||||
public function authenticate(Request $request): Passport
|
||||
{
|
||||
$username = $request->request->get(key: 'username');
|
||||
$password = $request->request->get(key: 'password');
|
||||
$password = $request->request->get(key: 'password');
|
||||
$csrfToken = $request->request->get(key: '_csrf_token');
|
||||
|
||||
$request->getSession()->set(name: Security::LAST_USERNAME, value: $username);
|
||||
@ -58,6 +51,10 @@ class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
|
||||
throw new UserNotFoundException();
|
||||
}
|
||||
|
||||
if (!$user->isVerified()) {
|
||||
throw new UserNotVerifiedException();
|
||||
}
|
||||
|
||||
return $user;
|
||||
}),
|
||||
|
||||
@ -82,7 +79,7 @@ class LoginFormAuthenticator extends AbstractLoginFormAuthenticator
|
||||
|
||||
protected function getLoginUrl(Request $request): string
|
||||
{
|
||||
return $this->router->generate(name: 'app_login');
|
||||
return $this->router->generate(name: 'security_login');
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user