- Ajout de la vue et du fonctionement de l'inscription.

- Ajout de la vue connexion.
This commit is contained in:
2025-01-29 10:24:13 +01:00
parent f2dd1047a1
commit 6f78a8a4a3
12 changed files with 1268 additions and 174 deletions

View File

@ -0,0 +1,44 @@
<?php
namespace App\Controller;
use App\Entity\User;
use App\Form\RegistrationType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Doctrine\ORM\EntityManagerInterface;
class RegistrationController extends AbstractController
{
private $entityManager;
public function __construct(EntityManagerInterface $entityManager) // Injection du service EntityManagerInterface
{
$this->entityManager = $entityManager;
}
#[Route('/registration', name: 'app_registration')]
public function register (Request $request): Response
{
$user = new User();
$form = $this->createForm(RegistrationType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// Utilisation de l'EntityManager injecté
$this->entityManager->persist($user);
$this->entityManager->flush();
$this->addFlash('success', 'Votre compte a été créé avec succès !');
return $this->redirectToRoute('home');
}
return $this->render('registration/index.html.twig', [
'form' => $form->createView(),
]);
}
}