Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

81 linhas
3.3KB

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