src/Controller/SecurityController.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  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\Core\Exception\CustomUserMessageAccountStatusException;
  8. use Symfony\Component\Security\Core\Exception\DisabledException;
  9. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  10. class SecurityController extends AbstractController
  11. {
  12.     #[Route(path'/'name'app_login')]
  13.     public function login(Request $requestAuthenticationUtils $authenticationUtils): Response
  14.     {
  15.         if ($this->getUser()) {
  16.             $user $this->getUser();
  17.             if ($user->isFilmmaker()) {
  18.                 return $this->redirectToRoute('admin');
  19.             }
  20.             
  21.             return $this->redirectToRoute('supporter_dashboard');
  22.         }
  23.         $returnUrl '/admin';
  24.         if ($request->query->get('returnUrl')) {
  25.             $returnUrl $request->query->get('returnUrl');
  26.         }
  27.         // get the login error if there is one
  28.         $error $authenticationUtils->getLastAuthenticationError();
  29.         // last username entered by the user
  30.         $lastUsername $authenticationUtils->getLastUsername();
  31.         if ($request->query->get('email')) {
  32.             $lastUsername urldecode($request->query->get('email'));
  33.         }
  34.         return $this->render('security/login.html.twig', [
  35.             'last_username' => $lastUsername
  36.             'error' => $error,
  37.             'returnUrl' => $returnUrl,
  38.         ]);
  39.     }
  40.     #[Route(path'/logout'name'app_logout')]
  41.     public function logout(): Response
  42.     {
  43.         return $this->redirect('/');
  44.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  45.     }
  46.     #[Route('/registration/thank-you'name'app_registration_thankyou')]
  47.     public function finishPage(Request $request)
  48.     {
  49.         return $this->render('registration/thankyou.html.twig');
  50.     }
  51. }