Registration and login perfect
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user