Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

SecurityController.php 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. }