diff --git a/migrations/Version20260319102614.php b/migrations/Version20260319102614.php new file mode 100644 index 0000000..6fde6fd --- /dev/null +++ b/migrations/Version20260319102614.php @@ -0,0 +1,41 @@ +addSql('ALTER TABLE "user" ADD company_name VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE "user" ADD siret VARCHAR(14) DEFAULT NULL'); + $this->addSql('ALTER TABLE "user" ADD address VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE "user" ADD postal_code VARCHAR(10) DEFAULT NULL'); + $this->addSql('ALTER TABLE "user" ADD city VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE "user" ADD phone VARCHAR(20) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE "user" DROP company_name'); + $this->addSql('ALTER TABLE "user" DROP siret'); + $this->addSql('ALTER TABLE "user" DROP address'); + $this->addSql('ALTER TABLE "user" DROP postal_code'); + $this->addSql('ALTER TABLE "user" DROP city'); + $this->addSql('ALTER TABLE "user" DROP phone'); + } +} diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 12d6573..783453c 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -13,7 +13,7 @@ use Symfony\Component\Validator\Validator\ValidatorInterface; class RegistrationController extends AbstractController { - #[Route('/inscription', name: 'app_register')] + #[Route('/inscription', name: 'app_register', methods: ['GET', 'POST'])] public function register( Request $request, UserPasswordHasherInterface $passwordHasher, @@ -25,14 +25,25 @@ class RegistrationController extends AbstractController } if ($request->isMethod('POST')) { + $type = $request->request->getString('type'); $user = new User(); - $user->setFirstName($request->request->getString('first_name')); - $user->setLastName($request->request->getString('last_name')); - $user->setEmail($request->request->getString('email')); + $user->setFirstName(trim($request->request->getString('first_name'))); + $user->setLastName(trim($request->request->getString('last_name'))); + $user->setEmail(trim($request->request->getString('email'))); $plainPassword = $request->request->getString('password'); $user->setPassword($passwordHasher->hashPassword($user, $plainPassword)); + if ('organizer' === $type) { + $user->setRoles(['ROLE_ORGANIZER']); + $user->setCompanyName(trim($request->request->getString('company_name'))); + $user->setSiret(trim($request->request->getString('siret'))); + $user->setAddress(trim($request->request->getString('address'))); + $user->setPostalCode(trim($request->request->getString('postal_code'))); + $user->setCity(trim($request->request->getString('city'))); + $user->setPhone(trim($request->request->getString('phone'))); + } + $errors = $validator->validate($user); if (0 === count($errors)) { $em->persist($user); @@ -47,6 +58,11 @@ class RegistrationController extends AbstractController } } - return $this->render('security/register.html.twig'); + return $this->render('security/register.html.twig', [ + 'breadcrumbs' => [ + ['name' => 'Accueil', 'url' => '/'], + ['name' => 'Inscription', 'url' => '/inscription'], + ], + ]); } } diff --git a/src/Entity/User.php b/src/Entity/User.php index fa3dc8e..c277d96 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -37,6 +37,24 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\Column(length: 255, unique: true, nullable: true)] private ?string $keycloakId = null; + #[ORM\Column(length: 255, nullable: true)] + private ?string $companyName = null; + + #[ORM\Column(length: 14, nullable: true)] + private ?string $siret = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $address = null; + + #[ORM\Column(length: 10, nullable: true)] + private ?string $postalCode = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $city = null; + + #[ORM\Column(length: 20, nullable: true)] + private ?string $phone = null; + #[ORM\Column] private \DateTimeImmutable $createdAt; @@ -125,6 +143,78 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface return $this->createdAt; } + public function getCompanyName(): ?string + { + return $this->companyName; + } + + public function setCompanyName(?string $companyName): static + { + $this->companyName = $companyName; + + return $this; + } + + public function getSiret(): ?string + { + return $this->siret; + } + + public function setSiret(?string $siret): static + { + $this->siret = $siret; + + return $this; + } + + public function getAddress(): ?string + { + return $this->address; + } + + public function setAddress(?string $address): static + { + $this->address = $address; + + return $this; + } + + public function getPostalCode(): ?string + { + return $this->postalCode; + } + + public function setPostalCode(?string $postalCode): static + { + $this->postalCode = $postalCode; + + return $this; + } + + public function getCity(): ?string + { + return $this->city; + } + + public function setCity(?string $city): static + { + $this->city = $city; + + return $this; + } + + public function getPhone(): ?string + { + return $this->phone; + } + + public function setPhone(?string $phone): static + { + $this->phone = $phone; + + return $this; + } + public function getKeycloakId(): ?string { return $this->keycloakId; diff --git a/templates/security/register.html.twig b/templates/security/register.html.twig index 31daebf..8fa96ab 100644 --- a/templates/security/register.html.twig +++ b/templates/security/register.html.twig @@ -1,7 +1,181 @@ {% extends 'base.html.twig' %} {% block title %}Inscription - E-Ticket{% endblock %} +{% block description %}Creez votre compte E-Ticket en tant qu'acheteur ou organisateur d'evenements{% endblock %} {% block body %} +
+

Inscription

+

Creez votre compte.

+ {% for message in app.flashes('success') %} +
+

{{ message }}

+
+ {% endfor %} + + {% for message in app.flashes('error') %} +
+

{{ message }}

+
+ {% endfor %} + +
+ + +
+ +
+
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
+ + + +
+

Deja un compte ? Connexion

+
+
{% endblock %}