traductions, sentry, form, mariadb, assets
Some checks failed
Cadoles/hydra-sql/pipeline/pr-develop There was a failure building this commit
Some checks failed
Cadoles/hydra-sql/pipeline/pr-develop There was a failure building this commit
This commit is contained in:
20
src/Controller/LocaleController.php
Normal file
20
src/Controller/LocaleController.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class LocaleController extends AbstractController
|
||||
{
|
||||
#[Route(path: 'locale/{locale}', name: 'locale_change')]
|
||||
public function changeLocal(string $locale, Request $request)
|
||||
{
|
||||
// On stocke la langue dans la session
|
||||
$request->getSession()->set('_locale', $locale);
|
||||
|
||||
// redirection
|
||||
return $this->redirect($request->headers->get('referer'));
|
||||
}
|
||||
}
|
@ -24,17 +24,13 @@ class MainController extends AbstractController
|
||||
$this->hydra = $hydra;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/", name="app_home")
|
||||
*/
|
||||
#[Route('/', name: 'app_home')]
|
||||
public function home(Request $request)
|
||||
{
|
||||
return $this->hydra->handleLoginRequest($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/connect/login-accept", name="app_login_accept")
|
||||
*/
|
||||
#[Route('/connect/login-accept', name: 'app_login_accept')]
|
||||
public function loginAccept(Request $request)
|
||||
{
|
||||
/** @var User */
|
||||
@ -47,9 +43,7 @@ class MainController extends AbstractController
|
||||
return new RedirectResponse($loginAcceptRes['redirect_to']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/connect/consent", name="app_consent")
|
||||
*/
|
||||
#[Route('/connect/consent', name: 'app_consent')]
|
||||
public function consent(Request $request)
|
||||
{
|
||||
return $this->hydra->handleConsentRequest($request);
|
||||
|
@ -2,32 +2,52 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Form\LoginType;
|
||||
use App\Security\PdoUserAuthenticator;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class SecurityController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/login", name="app_login")
|
||||
*/
|
||||
public function login(AuthenticationUtils $authenticationUtils): Response
|
||||
#[Route('/login', name: 'app_login')]
|
||||
public function login(ParameterBagInterface $params, AuthenticationUtils $authenticationUtils, Request $request, TranslatorInterface $trans): Response
|
||||
{
|
||||
// get the login error if there is one
|
||||
// Si l'utilisateur est déjà connecté on le renvoie sur la page du site demandeur
|
||||
if ($this->getUser()) {
|
||||
return new RedirectResponse($params->get('issuer_url'));
|
||||
}
|
||||
|
||||
// On fournit le form, mais il est traité par un authenticator
|
||||
$loginForm = $this->createForm(LoginType::class, null);
|
||||
$error = $authenticationUtils->getLastAuthenticationError();
|
||||
if ($error) {
|
||||
if ($request->getSession()->has(PdoUserAuthenticator::ERROR_LOGIN)) {
|
||||
$loginForm->get('login')->addError(new FormError($trans->trans('error.login', [], 'messages')));
|
||||
$request->getSession()->remove(PdoUserAuthenticator::ERROR_LOGIN);
|
||||
}
|
||||
if ($request->getSession()->has(PdoUserAuthenticator::ERROR_PASSWORD)) {
|
||||
$loginForm->get('password')->addError(new FormError($trans->trans('error.password', [], 'messages')));
|
||||
$request->getSession()->remove(PdoUserAuthenticator::ERROR_PASSWORD);
|
||||
}
|
||||
if ($request->getSession()->has(PdoUserAuthenticator::ERROR_PDO)) {
|
||||
$loginForm->addError(new FormError($trans->trans('error.pdo', [], 'messages')));
|
||||
$request->getSession()->remove(PdoUserAuthenticator::ERROR_PDO);
|
||||
}
|
||||
}
|
||||
// last username entered by the user
|
||||
$lastUsername = $authenticationUtils->getLastUsername();
|
||||
|
||||
return $this->render('login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
|
||||
return $this->render('login.html.twig', [
|
||||
'loginForm' => $loginForm->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/logout", name="app_logout")
|
||||
*/
|
||||
#[Route('/logout', name: 'logout')]
|
||||
public function logout(Request $request)
|
||||
{
|
||||
}
|
||||
|
Reference in New Issue
Block a user