src/Controller/SecurityController.php line 20
<?phpnamespace App\Controller;use App\Entity\User;use App\Form\CreateAccountType;use App\Service\Mail\MailService;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;use Symfony\Component\Routing\Annotation\Route;use Doctrine\ORM\EntityManagerInterface;use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;class SecurityController extends AbstractController{#[Route(path: '/login', name: 'login')]public function login(AuthenticationUtils $authenticationUtils): Response{if ($this->getUser()) {return $this->redirectToRoute('home');}// get the login error if there is one$error = $authenticationUtils->getLastAuthenticationError();// last username entered by the user$lastUsername = $authenticationUtils->getLastUsername();return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);}#[Route('/logout', name: 'logout')]public function logout(): void{}#[Route('/create_account', name: 'create_account')]public function createAccount(Request $request, UserPasswordHasherInterface $passwordHasher, EntityManagerInterface $manager, MailService $mailService): Response{$user = new User();$form = $this->createForm(CreateAccountType::class, $user);$form->handleRequest($request);if($form->isSubmitted() && $form->isValid()) {$password = $passwordHasher->hashPassword($user, $user->getPassword());$user->setPassword($password);$manager->persist($user);$manager->flush();$mailService->sendMailAccountCreation($user->getUserEmail(), $user->getUserName(), $user->getUserSurName());return $this->redirectToRoute('login');}return $this->render('security/create_account.html.twig', ['controller_name' => 'SecurityController','form' => $form->createView(),]);}}