diff --git a/.env b/.env index ac80863..495d52a 100644 --- a/.env +++ b/.env @@ -23,8 +23,8 @@ APP_SECRET= # Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url # IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml # -# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" -DATABASE_URL="mysql://kumora:kumora@127.0.0.1:3309/kumora?serverVersion=8.0.32&charset=utf8mb4" +DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" +# DATABASE_URL="mysql://kumora:kumora@127.0.0.1:3309/kumora?serverVersion=8.0.32&charset=utf8mb4" # DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4" # DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8" ###< doctrine/doctrine-bundle ### diff --git a/assets/controllers/.gitkeep b/assets/controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index e00d3ec..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - mysql: - image: mysql:8.4 - environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: kumora - MYSQL_USER: kumora - MYSQL_PASSWORD: kumora - ports: - - "3309:3306" - volumes: - - mysql_datas_kumora:/var/lib/mysql - -volumes: - mysql_datas_kumora: \ No newline at end of file diff --git a/migrations/Version20241228222158.php b/migrations/Version20241228222158.php deleted file mode 100644 index 633afd4..0000000 --- a/migrations/Version20241228222158.php +++ /dev/null @@ -1,33 +0,0 @@ -addSql('CREATE TABLE `user` (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', roles JSON NOT NULL, password VARCHAR(255) NOT NULL, username VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, approuved TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME (username), UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', available_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', delivered_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_75EA56E0FB7336F0 (queue_name), INDEX IDX_75EA56E0E3BD61CE (available_at), INDEX IDX_75EA56E016BA31DB (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP TABLE `user`'); - $this->addSql('DROP TABLE messenger_messages'); - } -} diff --git a/migrations/Version20241229133017.php b/migrations/Version20241229133017.php new file mode 100644 index 0000000..6ed3c1e --- /dev/null +++ b/migrations/Version20241229133017.php @@ -0,0 +1,37 @@ +addSql('CREATE TABLE "user" (id BLOB NOT NULL --(DC2Type:uuid) + , email VARCHAR(255) NOT NULL, roles CLOB NOT NULL --(DC2Type:json) + , password VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_EMAIL ON "user" (email)'); + $this->addSql('CREATE TABLE messenger_messages (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, body CLOB NOT NULL, headers CLOB NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable) + , available_at DATETIME NOT NULL --(DC2Type:datetime_immutable) + , delivered_at DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) + )'); + $this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)'); + $this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)'); + $this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP TABLE "user"'); + $this->addSql('DROP TABLE messenger_messages'); + } +} diff --git a/src/Command/CreateUserCommand.php b/src/Command/CreateUserCommand.php new file mode 100644 index 0000000..276a6e5 --- /dev/null +++ b/src/Command/CreateUserCommand.php @@ -0,0 +1,62 @@ +ask('Email de l\'utilisateur'); + $password = $io->askHidden('Mot de passe de l\'utilisateur'); + $isAdmin = $io->confirm('Est-ce un administrateur ?'); + + try { + $user = $this->userRepository->findOneBy(['email' => $email]); + if ($user) { + $io->error('Un utilisateur existe déjà avec cet email'); + return Command::FAILURE; + } + + $user = new User(); + $user->setEmail($email); + $user->setPassword($this->passwordHasher->hashPassword($user, $password)); + $user->setRoles($isAdmin ? ['ROLE_ADMIN'] : ['ROLE_USER']); + + $this->entityManager->persist($user); + $this->entityManager->flush(); + + $io->success('Utilisateur créé avec succès'); + } catch (\Exception $e) { + $io->error('Une erreur est survenue lors de la création de l\'utilisateur'); + } + + + return Command::SUCCESS; + } +} diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php deleted file mode 100644 index e3e9cd6..0000000 --- a/src/Controller/RegistrationController.php +++ /dev/null @@ -1,46 +0,0 @@ -isGranted('IS_AUTHENTICATED_FULLY')) { - return $this->redirectToRoute('app_home'); - } - $user = new User(); - $form = $this->createForm(RegistrationFormType::class, $user); - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - /** @var string $plainPassword */ - $plainPassword = $form->get('plainPassword')->getData(); - - // encode the plain password - $user->setPassword($userPasswordHasher->hashPassword($user, $plainPassword)); - - $entityManager->persist($user); - $entityManager->flush(); - - $this->addFlash('success', 'Votre compte a été créé avec succès. Vous recevrez un email de confirmation une fois que votre compte aura été approuvé.'); - - return $this->redirectToRoute('app_login'); - } - - return $this->render('registration/register.html.twig', [ - 'registrationForm' => $form, - ]); - } -} diff --git a/src/Entity/User.php b/src/Entity/User.php index 44cbb9b..1824b8d 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -11,15 +11,16 @@ use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: UserRepository::class)] #[ORM\Table(name: '`user`')] -#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_USERNAME', fields: ['username'])] #[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])] #[UniqueEntity(fields: ['email'], message: 'Un compte existe déjà avec cet email')] -#[UniqueEntity(fields: ['username'], message: 'Un compte existe déjà avec ce nom d\'utilisateur')] class User implements UserInterface, PasswordAuthenticatedUserInterface { #[ORM\Id] #[ORM\Column(type: 'uuid', length: 180)] - private ?Uuid $id = null; + private ?Uuid $id; + + #[ORM\Column(length: 255)] + private ?string $email = null; /** * @var list The user roles @@ -33,15 +34,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\Column] private ?string $password = null; - #[ORM\Column(length: 255)] - private ?string $username = null; - - #[ORM\Column(length: 255)] - private ?string $email = null; - - #[ORM\Column] - private ?bool $approuved = false; - public function __construct() { $this->id = Uuid::v4(); @@ -110,18 +102,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface // $this->plainPassword = null; } - public function getUsername(): ?string - { - return $this->username; - } - - public function setUsername(string $username): static - { - $this->username = $username; - - return $this; - } - public function getEmail(): ?string { return $this->email; @@ -133,16 +113,4 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface return $this; } - - public function isApprouved(): ?bool - { - return $this->approuved; - } - - public function setApprouved(bool $approuved): static - { - $this->approuved = $approuved; - - return $this; - } } diff --git a/src/Form/.gitkeep b/src/Form/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/Form/RegistrationFormType.php b/src/Form/RegistrationFormType.php deleted file mode 100644 index be5e7b0..0000000 --- a/src/Form/RegistrationFormType.php +++ /dev/null @@ -1,54 +0,0 @@ -add('username') - ->add('email') - ->add('plainPassword', PasswordType::class, [ - 'mapped' => false, - 'attr' => ['autocomplete' => 'new-password'], - 'constraints' => [ - new NotBlank([ - 'message' => 'Please enter a password', - ]), - new Length([ - 'min' => 6, - 'minMessage' => 'Your password should be at least {{ limit }} characters', - // max length allowed by Symfony for security reasons - 'max' => 4096, - ]), - ], - ]) - ->add('agreeTerms', CheckboxType::class, [ - 'mapped' => false, - 'constraints' => [ - new IsTrue([ - 'message' => 'Vous devez accepter les conditions d\'utilisation.', - ]), - ], - ]) - ; - } - - public function configureOptions(OptionsResolver $resolver): void - { - $resolver->setDefaults([ - 'data_class' => User::class, - ]); - } -} diff --git a/templates/home/index.html.twig b/templates/home/index.html.twig index 73e04b2..46d311c 100644 --- a/templates/home/index.html.twig +++ b/templates/home/index.html.twig @@ -1,20 +1,15 @@ {% extends 'base.html.twig' %} -{% block title %}Hello HomeController!{% endblock %} +{% block title %}Le cloud de Camélia-Studio{% endblock %} {% block body %} - - -
-

Hello {{ controller_name }}! ✅

- - This friendly message is coming from: - -
-{% endblock %} +
+

Bienvenue sur Kumora

+

Notre espace de stockage en ligne, dédié aux membres de Camélia Studio, pour faciliter le partage de tous les fichiers et ressources de l'association.

+ +
+{% endblock %} \ No newline at end of file diff --git a/templates/partials/navbar.html.twig b/templates/partials/navbar.html.twig index 9a24ace..e12f0ef 100644 --- a/templates/partials/navbar.html.twig +++ b/templates/partials/navbar.html.twig @@ -18,17 +18,16 @@
  • Liste des fichiers
  • -
  • - Administration -
  • {% if not is_granted('IS_AUTHENTICATED_FULLY') %}
  • Se connecter
  • -
  • - S'inscrire -
  • {% else %} + {% if is_granted('ROLE_ADMIN') %} +
  • + Administration +
  • + {% endif %}
  • Se déconnecter
  • diff --git a/templates/registration/register.html.twig b/templates/registration/register.html.twig deleted file mode 100644 index d53f1ae..0000000 --- a/templates/registration/register.html.twig +++ /dev/null @@ -1,24 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Register{% endblock %} - -{% block body %} -
    -
    -

    S'inscrire

    - - {{ form_errors(registrationForm) }} - - {{ form_start(registrationForm) }} - {{ form_row(registrationForm.username) }} - {{ form_row(registrationForm.email) }} - {{ form_row(registrationForm.plainPassword, { - label: 'Password' - }) }} - {{ form_row(registrationForm.agreeTerms) }} - - {{ form_end(registrationForm) }} -
    -
    - -{% endblock %} diff --git a/templates/security/login.html.twig b/templates/security/login.html.twig index bac91d9..446c572 100644 --- a/templates/security/login.html.twig +++ b/templates/security/login.html.twig @@ -23,7 +23,7 @@
    - +