Registration and login perfect

This commit is contained in:
Olivier PARPAILLON
2024-11-19 15:58:04 +01:00
parent dc01c2e216
commit e10becf01d
10 changed files with 118 additions and 171 deletions

View File

@@ -4,6 +4,8 @@ namespace App\Controller;
use App\Entity\Participant;
use App\Form\RegistrationFormType;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\DBAL\Schema\Exception\UniqueConstraintDoesNotExist;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\SecurityBundle\Security;
@@ -35,8 +37,13 @@ class RegistrationController extends AbstractController
$user->setAdministrateur(false);
}
$entityManager->persist($user);
$entityManager->flush();
try {
$entityManager->persist($user);
$entityManager->flush();
} catch (UniqueConstraintViolationException $e) {
$this->addFlash('error', 'Cet email ou pseudo est déjà utilisé, veuillez en choisir un autre.');
return $this->redirectToRoute('app_register');
}
// do anything else you need here, like send an email