modification de l'authenticator pour former l'url de login en comprenant le baseUrl
Some checks are pending
Cadoles/hydra-sql/pipeline/pr-develop Build started...
Cadoles/hydra-sql/pipeline/head This commit looks good

This commit is contained in:
2023-01-06 15:26:53 +01:00
parent 0996ce6402
commit e5a27850c3
2 changed files with 9 additions and 12 deletions

View File

@ -13,13 +13,13 @@ 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\AbstractAuthenticator;
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 AbstractAuthenticator
class SQLLoginUserAuthenticator extends AbstractLoginFormAuthenticator
{
public const LOGIN_ROUTE = 'app_login';
public const ERROR_LOGIN = 'error_login';
@ -52,11 +52,11 @@ class SQLLoginUserAuthenticator extends AbstractAuthenticator
return new RedirectResponse($this->baseUrl.'/connect/login-accept');
}
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response
{
$request->getSession()->set(Security::AUTHENTICATION_ERROR, $exception);
return new RedirectResponse($this->baseUrl.'/connect/login-accept');
return new RedirectResponse($this->baseUrl.'/login');
}
public function authenticate(Request $request): Passport
@ -100,4 +100,9 @@ class SQLLoginUserAuthenticator extends AbstractAuthenticator
$request->getSession()->set(self::ERROR_LOGIN, true);
throw new AuthenticationException();
}
protected function getLoginUrl(Request $request): string
{
return $this->baseUrl.'/login';
}
}