src/Controller/SecurityController.php line 25
<?php
namespace App\Controller;
use App\Repository\SettingsRepository;
use Exception;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends AbstractController
{
#[Route(path: '/login', name: 'login_non_locale')]
public function login_non_locale(Request $request): Response
{
return $this->redirectToRoute("login",["_locale"=>$request->getLocale()]);
}
#[Route(path: '/{_locale}/login', name: 'login')]
public function login(AuthenticationUtils $authenticationUtils,SettingsRepository $settingsRepository): Response
{
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
$settingsMain = $settingsRepository->findOneBy(["code"=>"main"]);
$twigParams = [
// parameters usually defined in Symfony login forms
'error' => $error,
'last_username' => $lastUsername,
// OPTIONAL parameters to customize the login form:
// the translation_domain to use (define this option only if you are
// rendering the login template in a regular Symfony controller; when
// rendering it from an EasyAdmin Dashboard this is automatically set to
// the same domain as the rest of the Dashboard)
'translation_domain' => 'admin',
// by default EasyAdmin displays a black square as its default favicon;
// use this method to display a custom favicon: the given path is passed
// "as is" to the Twig asset() function:
// <link rel="shortcut icon" href="{{ asset('...') }}">
'background_body'=>"url('/themes/".strtolower($settingsMain->getAssetFolderName())."/admin/images/bg-body.jpg')",
'favicon_path' => "/themes/".strtolower($settingsMain->getAssetFolderName())."/admin/images/favicon.png",
// the title visible above the login form (define this option only if you are
// rendering the login template in a regular Symfony controller; when rendering
// it from an EasyAdmin Dashboard this is automatically set as the Dashboard title)
'page_title' => '<img width="200" class="mb-3 mt-5" src="/themes/'.strtolower($settingsMain->getAssetFolderName()).'/images/logo.png" />',
// the string used to generate the CSRF token. If you don't define
// this parameter, the login form won't include a CSRF token
'csrf_token_intention' => 'authenticate',
// the URL users are redirected to after the login (default: '/admin')
//'target_path' => $this->generateUrl('admin'),
// the label displayed for the username form field (the |trans filter is applied to it)
'username_label' => 'Nom d\'utilisateur',
// the label displayed for the password form field (the |trans filter is applied to it)
'password_label' => 'Mot de passe',
// the label displayed for the Sign In form button (the |trans filter is applied to it)
'sign_in_label' => 'Se connecter',
// the 'name' HTML attribute of the <input> used for the username field (default: '_username')
'username_parameter' => 'username',
// the 'name' HTML attribute of the <input> used for the password field (default: '_password')
'password_parameter' => 'password',
// whether to enable or not the "forgot password?" link (default: false)
'forgot_password_enabled' => false,
// the path (i.e. a relative or absolute URL) to visit when clicking the "forgot password?" link (default: '#')
//'forgot_password_path' => $this->generateUrl('...', ['...' => '...']),
// the label displayed for the "forgot password?" link (the |trans filter is applied to it)
'forgot_password_label' => 'Forgot your password?',
// whether to enable or not the "remember me" checkbox (default: false)
'remember_me_enabled' => true,
// remember me name form field (default: '_remember_me')
'remember_me_parameter' => 'remember_me',
// whether to check by default the "remember me" checkbox (default: false)
'remember_me_checked' => false,
// the label displayed for the remember me checkbox (the |trans filter is applied to it)
'remember_me_label' => 'Se souvenir de moi',
];
return $this->render('@Flexy/FrontBundle/Themes/'.$settingsMain->getFrontTheme().'/templates/admin/easyadmin/page/login.html.twig', $twigParams);
try{
}catch(Exception $ex){
return $this->render('@EasyAdmin/page/login.html.twig', $twigParams);
}
}
#[Route(path: '/{_locale}/logout', name: 'app_logout')]
public function logout(): never
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
}