src/Controller/SecurityController.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\User;
  4. use App\Entity\Company;
  5. use App\Entity\CompanyGroup;
  6. use App\Repository\UserRepository;
  7. use App\Repository\CompanyRepository;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  13. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  14. use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
  15. class SecurityController extends AbstractController
  16. {
  17.     /**
  18.      * @Route("/login", name="app_login")
  19.      */
  20.     public function login(AuthenticationUtils $authenticationUtilsUserRepository $userRepository): Response
  21.     {
  22.         $user $userRepository->find(2);
  23.         ///dump($user);
  24.         $error $authenticationUtils->getLastAuthenticationError();
  25.         $lastUsername $authenticationUtils->getLastUsername();
  26.         return $this->render('@EasyAdmin/page/login.html.twig', [
  27.             // parameters usually defined in Symfony login forms
  28.             'error' => $error,
  29.             'last_username' => $lastUsername,
  30.             // OPTIONAL parameters to customize the login form:
  31.             // the translation_domain to use (define this option only if you are
  32.             // rendering the login template in a regular Symfony controller; when
  33.             // rendering it from an EasyAdmin Dashboard this is automatically set to
  34.             // the same domain as the rest of the Dashboard)
  35.             'translation_domain' => 'admin',
  36.             // the title visible above the login form (define this option only if you are
  37.             // rendering the login template in a regular Symfony controller; when rendering
  38.             // it from an EasyAdmin Dashboard this is automatically set as the Dashboard title)
  39.             'page_title' => 'ABS CASH',
  40.             // the string used to generate the CSRF token. If you don't define
  41.             // this parameter, the login form won't include a CSRF token
  42.             'csrf_token_intention' => 'authenticate',
  43.             // the URL users are redirected to after the login (default: '/admin')
  44.             'target_path' => $this->generateUrl('home'),
  45.             // the label displayed for the username form field (the |trans filter is applied to it)
  46.             'username_label' => 'Podaj adres email',
  47.             // the label displayed for the password form field (the |trans filter is applied to it)
  48.             'password_label' => 'Podaj hasło',
  49.             // the label displayed for the Sign In form button (the |trans filter is applied to it)
  50.             'sign_in_label' => 'Zaloguj się',
  51.             // whether to enable or not the "remember me" checkbox (default: false)
  52.             'remember_me_enabled' => true,
  53.             // remember me name form field (default: '_remember_me')
  54.             'remember_me_parameter' => 'custom_remember_me_param',
  55.             // whether to check by default the "remember me" checkbox (default: false)
  56.             'remember_me_checked' => true,
  57.             // the label displayed for the remember me checkbox (the |trans filter is applied to it)
  58.             'remember_me_label' => 'Zapamiętaj mnie',
  59.         ]);
  60.     }
  61.     /**
  62.      * @Route("/logout", name="app_logout", methods={"GET"})
  63.      */
  64.     public function logout(): void
  65.     {
  66.         // controller can be blank: it will never be called!
  67.         throw new \Exception('Don\'t forget to activate logout in security.yaml');
  68.     }
  69.  
  70. }