complément logs et exceptions #20
|
@ -29,11 +29,11 @@ class SecurityController extends AbstractController
|
||||||
$error = $authenticationUtils->getLastAuthenticationError();
|
$error = $authenticationUtils->getLastAuthenticationError();
|
||||||
if ($error) {
|
if ($error) {
|
||||||
if ($request->getSession()->has(SQLLoginUserAuthenticator::ERROR_LOGIN)) {
|
if ($request->getSession()->has(SQLLoginUserAuthenticator::ERROR_LOGIN)) {
|
||||||
$loginForm->get('login')->addError(new FormError($trans->trans('error.login', [], 'messages')));
|
$loginForm->addError(new FormError($trans->trans('error.login', [], 'messages')));
|
||||||
$request->getSession()->remove(SQLLoginUserAuthenticator::ERROR_LOGIN);
|
$request->getSession()->remove(SQLLoginUserAuthenticator::ERROR_LOGIN);
|
||||||
}
|
}
|
||||||
if ($request->getSession()->has(SQLLoginUserAuthenticator::ERROR_PASSWORD)) {
|
if ($request->getSession()->has(SQLLoginUserAuthenticator::ERROR_PASSWORD)) {
|
||||||
$loginForm->get('password')->addError(new FormError($trans->trans('error.password', [], 'messages')));
|
$loginForm->addError(new FormError($trans->trans('error.login', [], 'messages')));
|
||||||
$request->getSession()->remove(SQLLoginUserAuthenticator::ERROR_PASSWORD);
|
$request->getSession()->remove(SQLLoginUserAuthenticator::ERROR_PASSWORD);
|
||||||
}
|
}
|
||||||
if ($request->getSession()->has(SQLLoginUserAuthenticator::ERROR_PDO)) {
|
if ($request->getSession()->has(SQLLoginUserAuthenticator::ERROR_PDO)) {
|
||||||
|
|
|
@ -69,7 +69,10 @@ class SQLLoginRequest
|
||||||
public function getRequestScope()
|
public function getRequestScope()
|
||||||
{
|
{
|
||||||
$scope = '';
|
$scope = '';
|
||||||
if ($this->config[self::DATA_TO_FETCH]) {
|
if (!$this->config[self::DATA_TO_FETCH]) {
|
||||||
|
|||||||
|
throw new NullDataToFetchException();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->config[self::DATA_TO_FETCH] as $data) {
|
foreach ($this->config[self::DATA_TO_FETCH] as $data) {
|
||||||
$scope .= $data . ',';
|
$scope .= $data . ',';
|
||||||
}
|
}
|
||||||
|
@ -78,8 +81,6 @@ class SQLLoginRequest
|
||||||
|
|
||||||
return 'SELECT ' . $scope . ' FROM ' . $this->getTableName() . ' WHERE ' . $this->getLoginColumnName() . ' = :' . $this->getLoginColumnName() . ';';
|
return 'SELECT ' . $scope . ' FROM ' . $this->getTableName() . ' WHERE ' . $this->getLoginColumnName() . ' = :' . $this->getLoginColumnName() . ';';
|
||||||
}
|
}
|
||||||
throw new NullDataToFetchException();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construction de la string pour la requête préparée selon la configuration yaml
|
* Construction de la string pour la requête préparée selon la configuration yaml
|
||||||
|
|
|
@ -12,14 +12,12 @@ use App\SQLLogin\Exception\LoginElementsConfigurationException;
|
||||||
use App\SQLLogin\Exception\SecurityPatternConfigurationException;
|
use App\SQLLogin\Exception\SecurityPatternConfigurationException;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator;
|
use Symfony\Component\Security\Http\Authenticator\AbstractLoginFormAuthenticator;
|
||||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge;
|
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\Badge\UserBadge;
|
||||||
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
|
|
||||||
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
|
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
|
||||||
|
|
||||||
class SQLLoginUserAuthenticator extends AbstractLoginFormAuthenticator
|
class SQLLoginUserAuthenticator extends AbstractLoginFormAuthenticator
|
||||||
|
@ -54,19 +52,19 @@ class SQLLoginUserAuthenticator extends AbstractLoginFormAuthenticator
|
||||||
return self::LOGIN_ROUTE === $request->attributes->get('_route') && $request->isMethod('POST');
|
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);
|
$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');
|
$form = $request->request->get('login');
|
||||||
$login = $form['login'];
|
$login = $form['login'];
|
||||||
|
|
|
@ -51,7 +51,7 @@ class SQLLoginService extends AbstractController
|
||||||
return $datas;
|
return $datas;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetchPassword(string $login)
|
public function fetchPassword($login): array|bool
|
||||||
vcarroy
commented
typer $login (mixed possible) typer $login (mixed possible)
rmasson
commented
ok ok
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$dbh = $this->getConnection();
|
$dbh = $this->getConnection();
|
||||||
|
|
|
@ -7,11 +7,7 @@
|
||||||
<body>
|
<body>
|
||||||
<trans-unit id="fXVg5Zq" resname="error.login">
|
<trans-unit id="fXVg5Zq" resname="error.login">
|
||||||
<source>error.login</source>
|
<source>error.login</source>
|
||||||
<target>Incorrect login</target>
|
<target>Incorrect login or password</target>
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="8VJKwdK" resname="error.password">
|
|
||||||
<source>error.password</source>
|
|
||||||
<target>Incorrect password</target>
|
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="36t19qm" resname="error.sql_login">
|
<trans-unit id="36t19qm" resname="error.sql_login">
|
||||||
<source>error.sql_login</source>
|
<source>error.sql_login</source>
|
||||||
|
|
|
@ -7,11 +7,7 @@
|
||||||
<body>
|
<body>
|
||||||
<trans-unit id="fXVg5Zq" resname="error.login">
|
<trans-unit id="fXVg5Zq" resname="error.login">
|
||||||
<source>error.login</source>
|
<source>error.login</source>
|
||||||
<target>Login incorrect ou inconnu</target>
|
<target>Login ou mot de passe inconnu</target>
|
||||||
</trans-unit>
|
|
||||||
<trans-unit id="8VJKwdK" resname="error.password">
|
|
||||||
<source>error.password</source>
|
|
||||||
<target>Mot de passe incorrect</target>
|
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="36t19qm" resname="error.sql_login">
|
<trans-unit id="36t19qm" resname="error.sql_login">
|
||||||
<source>error.sql_login</source>
|
<source>error.sql_login</source>
|
||||||
|
|
Loading…
Reference in New Issue
Inverser cette condition
ok