Loading src/Dto/UtilisateurInscriptionInput.php +4 −2 Changes for src/Dto/UtilisateurInscriptionInput.php: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -12,12 +12,14 @@ class UtilisateurInscriptionInput #[Groups(['user:register'])] public string $email; #[Groups(['user:register'])] public ?string $username; #[Assert\NotBlank] #[Assert\Length(min: 4)] #[Groups(['user:register'])] public string $plainPassword; #[Assert\NotBlank] #[Groups(['user:register'])] public string $typeConnexion; public ?string $typeConnexion; } src/Entity/AbstractUser.php +1 −0 Changes for src/Entity/AbstractUser.php: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ abstract class AbstractUser implements UserInterface, PasswordAuthenticatedUserI protected ?int $id = null; #[ORM\Column(length: 180, unique: true, nullable: true)] #[Groups(['user:read', 'user:create', 'user:update'])] protected ?string $username = null; #[Assert\NotBlank] Loading src/State/UtilisateurInscriptionProcessor.php +10 −4 Changes for src/State/UtilisateurInscriptionProcessor.php: 10 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -24,12 +24,18 @@ class UtilisateurInscriptionProcessor implements ProcessorInterface /** @var UtilisateurInscriptionInput $data */ $user = new User(); $user->setEmail($data->email); if(!$data->username){ $user->setUsername($data->email); } else { $user->setUsername($data->username); } $user->setPassword($this->hasher->hashPassword($user, $data->plainPassword)); $roleUser = $this->em->getRepository(Role::class)->findOneBy(['code' => 'ROLE_USER']); if ($roleUser) { $user->addRole($roleUser); } /** @TODO: Gérer le role par défaut */ // $roleUser = $this->em->getRepository(Role::class)->findOneBy(['code' => 'ROLE_USER']); // if ($roleUser) { // $user->addRole($roleUser); // } $this->em->persist($user); $this->em->flush(); Loading Loading
src/Dto/UtilisateurInscriptionInput.php +4 −2 Changes for src/Dto/UtilisateurInscriptionInput.php: 4 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -12,12 +12,14 @@ class UtilisateurInscriptionInput #[Groups(['user:register'])] public string $email; #[Groups(['user:register'])] public ?string $username; #[Assert\NotBlank] #[Assert\Length(min: 4)] #[Groups(['user:register'])] public string $plainPassword; #[Assert\NotBlank] #[Groups(['user:register'])] public string $typeConnexion; public ?string $typeConnexion; }
src/Entity/AbstractUser.php +1 −0 Changes for src/Entity/AbstractUser.php: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ abstract class AbstractUser implements UserInterface, PasswordAuthenticatedUserI protected ?int $id = null; #[ORM\Column(length: 180, unique: true, nullable: true)] #[Groups(['user:read', 'user:create', 'user:update'])] protected ?string $username = null; #[Assert\NotBlank] Loading
src/State/UtilisateurInscriptionProcessor.php +10 −4 Changes for src/State/UtilisateurInscriptionProcessor.php: 10 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -24,12 +24,18 @@ class UtilisateurInscriptionProcessor implements ProcessorInterface /** @var UtilisateurInscriptionInput $data */ $user = new User(); $user->setEmail($data->email); if(!$data->username){ $user->setUsername($data->email); } else { $user->setUsername($data->username); } $user->setPassword($this->hasher->hashPassword($user, $data->plainPassword)); $roleUser = $this->em->getRepository(Role::class)->findOneBy(['code' => 'ROLE_USER']); if ($roleUser) { $user->addRole($roleUser); } /** @TODO: Gérer le role par défaut */ // $roleUser = $this->em->getRepository(Role::class)->findOneBy(['code' => 'ROLE_USER']); // if ($roleUser) { // $user->addRole($roleUser); // } $this->em->persist($user); $this->em->flush(); Loading