From fc222f516ce87d5e4c74ef36d1099ac254d220fd Mon Sep 17 00:00:00 2001 From: barillote Date: Thu, 21 Nov 2024 16:17:24 +0100 Subject: [PATCH] roles --- migrations/Version20241121151633.php | 31 +++++++++++++++++++++++ src/Controller/RegistrationController.php | 2 ++ src/Entity/UserApp.php | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 migrations/Version20241121151633.php diff --git a/migrations/Version20241121151633.php b/migrations/Version20241121151633.php new file mode 100644 index 0000000..b9a833a --- /dev/null +++ b/migrations/Version20241121151633.php @@ -0,0 +1,31 @@ +addSql('CREATE SCHEMA public'); + } +} diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index b078d9d..50e84c2 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -28,6 +28,7 @@ class RegistrationController extends AbstractController /** @var string $plainPassword */ $plainPassword = $form->get('plainPassword')->getData(); + $user->setRoles(['ROLE_INTERN']); // encode the plain password $user->setPassword($userPasswordHasher->hashPassword($user, $plainPassword)); @@ -55,6 +56,7 @@ class RegistrationController extends AbstractController /** @var string $plainPassword */ $plainPassword = $form->get('plainPassword')->getData(); + $user->setRoles(['ROLE_EMPLOYEE']); // encode the plain password $user->setPassword($userPasswordHasher->hashPassword($user, $plainPassword)); diff --git a/src/Entity/UserApp.php b/src/Entity/UserApp.php index 8f87ba6..7dabaa2 100644 --- a/src/Entity/UserApp.php +++ b/src/Entity/UserApp.php @@ -29,7 +29,7 @@ class UserApp implements UserInterface, PasswordAuthenticatedUserInterface * @var list The user roles */ #[ORM\Column] - private array $roles = ["ROLE_USER"]; + private array $roles = []; /** * @var string The hashed password