<?php
declare(strict_types=1);
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\HttpFoundation\{Response, RedirectResponse};
use Symfony\Component\Routing\Annotation\Route;
class LoginController extends AbstractController
{
#[Route('/login', name: 'login')]
public function index(AuthenticationUtils $authenticationUtils): Response
{
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('login/index.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
]);
}
#[Route('/logout', name: 'logout')]
public function logout(): void
{
}
#[Route('/login-success', name: 'login_success')]
public function loginSuccess(): RedirectResponse
{
if(true === $this->isGranted('ROLE_CUSTOMER')) {
return $this->redirectToRoute('customer_homepage');
}
return $this->redirectToRoute('campaign_my_campaigns_index');
}
}