<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;
use Symfony\Component\Security\Core\Exception\DisabledException;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends AbstractController
{
#[Route(path: '/', name: 'app_login')]
public function login(Request $request, AuthenticationUtils $authenticationUtils): Response
{
if ($this->getUser()) {
$user = $this->getUser();
if ($user->isFilmmaker()) {
return $this->redirectToRoute('admin');
}
return $this->redirectToRoute('supporter_dashboard');
}
$returnUrl = '/admin';
if ($request->query->get('returnUrl')) {
$returnUrl = $request->query->get('returnUrl');
}
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
if ($request->query->get('email')) {
$lastUsername = urldecode($request->query->get('email'));
}
return $this->render('security/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
'returnUrl' => $returnUrl,
]);
}
#[Route(path: '/logout', name: 'app_logout')]
public function logout(): Response
{
return $this->redirect('/');
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
#[Route('/registration/thank-you', name: 'app_registration_thankyou')]
public function finishPage(Request $request)
{
return $this->render('registration/thankyou.html.twig');
}
}