Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

73 lines
3.2KB

  1. <?php
  2. namespace Lc\SovBundle\Controller\Admin;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  7. class SecurityController extends AbstractController
  8. {
  9. public function login(AuthenticationUtils $authenticationUtils): Response
  10. {
  11. if ($this->getUser()) {
  12. return $this->redirectToRoute('lc_');
  13. }
  14. // get the login error if there is one
  15. $error = $authenticationUtils->getLastAuthenticationError();
  16. // last username entered by the user
  17. $lastUsername = $authenticationUtils->getLastUsername();
  18. return $this->render('@EasyAdmin/page/login.html.twig', [
  19. // parameters usually defined in Symfony login forms
  20. 'error' => $error,
  21. 'last_username' => $lastUsername,
  22. // OPTIONAL parameters to customize the login form:
  23. // the translation_domain to use (define this option only if you are
  24. // rendering the login template in a regular Symfony controller; when
  25. // rendering it from an EasyAdmin Dashboard this is automatically set to
  26. // the same domain as the rest of the Dashboard)
  27. 'translation_domain' => 'admin',
  28. // the title visible above the login form (define this option only if you are
  29. // rendering the login template in a regular Symfony controller; when rendering
  30. // it from an EasyAdmin Dashboard this is automatically set as the Dashboard title)
  31. 'page_title' => '<img src="assets/img/laclic.png" >',
  32. // the string used to generate the CSRF token. If you don't define
  33. // this parameter, the login form won't include a CSRF token
  34. 'csrf_token_intention' => 'authenticate',
  35. // the URL users are redirected to after the login (default: '/admin')
  36. 'target_path' => $this->generateUrl('lc_admin_dashboard'),
  37. // the label displayed for the username form field (the |trans filter is applied to it)
  38. 'username_label' => 'Your username',
  39. // the label displayed for the password form field (the |trans filter is applied to it)
  40. 'password_label' => 'Your password',
  41. // the label displayed for the Sign In form button (the |trans filter is applied to it)
  42. 'sign_in_label' => 'Log in',
  43. // the 'name' HTML attribute of the <input> used for the username field (default: '_username')
  44. 'username_parameter' => 'email',
  45. // the 'name' HTML attribute of the <input> used for the password field (default: '_password')
  46. 'password_parameter' => 'password',
  47. ]);
  48. }
  49. public function logout()
  50. {
  51. throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  52. }
  53. }