SHARE
TWEET

Untitled

a guest Jan 15th, 2020 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace App\Security;
  4.  
  5. [.....]
  6.  
  7. /**
  8.  * Class LoginFormAuthenticator
  9.  */
  10. class LoginFormAuthenticator extends AbstractFormLoginAuthenticator
  11. {
  12.     use TargetPathTrait;
  13.  
  14.     private $entityManager;
  15.     private $urlGenerator;
  16.     private $csrfTokenManager;
  17.     private $passwordEncoder;
  18.     /** @var Request $request */
  19.     private $request
  20.     public function __construct(EntityManagerInterface $entityManager, UrlGeneratorInterface $urlGenerator, CsrfTokenManagerInterface $csrfTokenManager, UserPasswordEncoderInterface $passwordEncoder, RequestStack $rs)
  21.     {
  22.         $this->entityManager = $entityManager;
  23.         $this->urlGenerator = $urlGenerator;
  24.         $this->csrfTokenManager = $csrfTokenManager;
  25.         $this->passwordEncoder = $passwordEncoder;
  26.         $this->request = $rs->getCurrentRequest();
  27.     }
  28.  
  29.     [....]
  30.  
  31.     public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
  32.     {
  33.         if ($targetPath = $this->getTargetPath($request->getSession(), $providerKey)) {
  34.             return new RedirectResponse($targetPath);
  35.         }
  36.  
  37.         $url = $this->urlGenerator->generate('index');
  38.  
  39.         return new RedirectResponse($url);
  40.     }
  41.  
  42.     protected function getLoginUrl()
  43.     {
  44.         return $this->urlGenerator->generate('app_login', [ array of parameters ]);
  45.     }
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top