feat (gestion exceptions) #19: traitement retour: typage, un seul message pour erreur login ou mdp
Some checks reported warnings
Cadoles/hydra-sql/pipeline/pr-develop This commit is unstable
Some checks reported warnings
Cadoles/hydra-sql/pipeline/pr-develop This commit is unstable
This commit is contained in:
@ -12,14 +12,12 @@ use App\SQLLogin\Exception\LoginElementsConfigurationException;
|
||||
use App\SQLLogin\Exception\SecurityPatternConfigurationException;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator;
|
||||
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\Passport;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
|
||||
|
||||
class SQLLoginUserAuthenticator extends AbstractLoginFormAuthenticator
|
||||
@ -54,19 +52,19 @@ class SQLLoginUserAuthenticator extends AbstractLoginFormAuthenticator
|
||||
return self::LOGIN_ROUTE === $request->attributes->get('_route') && $request->isMethod('POST');
|
||||
}
|
||||
|
||||
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): ?Response
|
||||
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): RedirectResponse
|
||||
{
|
||||
return new RedirectResponse($this->baseUrl.'/connect/login-accept');
|
||||
return new RedirectResponse($this->baseUrl . '/connect/login-accept');
|
||||
}
|
||||
|
||||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response
|
||||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): RedirectResponse
|
||||
{
|
||||
$request->getSession()->set(Security::AUTHENTICATION_ERROR, $exception);
|
||||
|
||||
return new RedirectResponse($this->baseUrl.'/login');
|
||||
return new RedirectResponse($this->baseUrl . '/login');
|
||||
}
|
||||
|
||||
public function authenticate(Request $request): Passport
|
||||
public function authenticate(Request $request): SelfValidatingPassport
|
||||
{
|
||||
$form = $request->request->get('login');
|
||||
$login = $form['login'];
|
||||
@ -120,6 +118,6 @@ class SQLLoginUserAuthenticator extends AbstractLoginFormAuthenticator
|
||||
|
||||
protected function getLoginUrl(Request $request): string
|
||||
{
|
||||
return $this->baseUrl.'/login';
|
||||
return $this->baseUrl . '/login';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user