diff --git a/composer.json b/composer.json index 91f6138..3388879 100644 --- a/composer.json +++ b/composer.json @@ -50,6 +50,7 @@ "symfony/string": "7.3.*", "symfony/translation": "7.3.*", "symfony/twig-bundle": "7.3.*", + "symfony/uid": "7.3.*", "symfony/validator": "7.3.*", "symfony/web-link": "7.3.*", "symfony/yaml": "7.3.*", diff --git a/composer.lock b/composer.lock index 894db06..ecf056e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b8542f5daf01c26d6b7aa9aa24c49b4e", + "content-hash": "7271bea1fd76a2d50dba48bc7d223135", "packages": [ { "name": "aws/aws-crt-php", @@ -7619,6 +7619,85 @@ ], "time": "2025-02-20T12:04:08+00:00" }, + { + "name": "symfony/polyfill-uuid", + "version": "v1.32.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-uuid.git", + "reference": "21533be36c24be3f4b1669c4725c7d1d2bab4ae2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/21533be36c24be3f4b1669c4725c7d1d2bab4ae2", + "reference": "21533be36c24be3f4b1669c4725c7d1d2bab4ae2", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-uuid": "*" + }, + "suggest": { + "ext-uuid": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Uuid\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Grégoire Pineau", + "email": "lyrixx@lyrixx.info" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for uuid functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "uuid" + ], + "support": { + "source": "https://github.com/symfony/polyfill-uuid/tree/v1.32.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, { "name": "symfony/process", "version": "v7.3.0", @@ -9214,6 +9293,80 @@ ], "time": "2025-06-27T19:55:54+00:00" }, + { + "name": "symfony/uid", + "version": "v7.3.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/uid.git", + "reference": "a69f69f3159b852651a6bf45a9fdd149520525bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/uid/zipball/a69f69f3159b852651a6bf45a9fdd149520525bb", + "reference": "a69f69f3159b852651a6bf45a9fdd149520525bb", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-uuid": "^1.15" + }, + "require-dev": { + "symfony/console": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Uid\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Grégoire Pineau", + "email": "lyrixx@lyrixx.info" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to generate and represent UIDs", + "homepage": "https://symfony.com", + "keywords": [ + "UID", + "ulid", + "uuid" + ], + "support": { + "source": "https://github.com/symfony/uid/tree/v7.3.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-06-27T19:55:54+00:00" + }, { "name": "symfony/validator", "version": "v7.3.1", diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index e45e8e1..4254ded 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -46,7 +46,7 @@ RUN npm install -g mjml # Configurer et installer les extensions PHP # Utilisation de -j$(nproc) pour paralléliser la compilation et accélérer le build RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \ - && docker-php-ext-install -j$(nproc) gd pdo pdo_pgsql zip gmp bcmath intl + && docker-php-ext-install -j$(nproc) gd pdo pdo_pgsql zip gmp bcmath intl exif # Installer Redis via pecl RUN pecl install redis && docker-php-ext-enable redis diff --git a/phpunit.dist.xml b/phpunit.dist.xml index 1f21435..a08415f 100644 --- a/phpunit.dist.xml +++ b/phpunit.dist.xml @@ -42,6 +42,9 @@ src + src/Controller + src/Command + src/Service diff --git a/sonar-project.properties b/sonar-project.properties index 921243c..8073979 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -17,3 +17,8 @@ sonar.sourceEncoding=UTF-8 sonar.tests=tests sonar.sources=src + +sonar.coverage.exclusions= \ + src/Controller/**/*.php, \ + src/Service/**/*.php, \ + src/Command/*.php diff --git a/src/Command/AccountCommand.php b/src/Command/AccountCommand.php new file mode 100644 index 0000000..c971af8 --- /dev/null +++ b/src/Command/AccountCommand.php @@ -0,0 +1,44 @@ +title("Création d'un utilisateur administrateur"); + + $userExit = $this->entityManager->getRepository(Account::class)->findOneBy(['email'=>'jovann@siteconseil.fr']); + if(!$userExit instanceof Account){ + $userExit = new Account(); + $userExit->setRoles(['ROLE_ROOT']); + $userExit->setUuid(Uuid::v4()); + $userExit->setEmail("jovann@siteconseil.fr"); + $userExit->setUsername("jovann"); + $userExit->setPassword($this->userPasswordHasher->hashPassword($userExit, 'jovann')); + + $this->eventDispatcher->dispatch(new CreatedAdminEvent($userExit,"jovann")); + } + + return Command::SUCCESS; + } +} diff --git a/src/Controller/Artemis/DashboardController.php b/src/Controller/Artemis/DashboardController.php new file mode 100644 index 0000000..5fd665a --- /dev/null +++ b/src/Controller/Artemis/DashboardController.php @@ -0,0 +1,17 @@ +getUser()) { + return $this->redirectToRoute('artemis_dashboard'); + } return$this->render('admin/login.twig',[ 'last_username' => $authenticationUtils->getLastUsername(), 'error' => $authenticationUtils->getLastAuthenticationError(), diff --git a/src/Service/Mailer/Event/CreatedAdminEvent.php b/src/Service/Mailer/Event/CreatedAdminEvent.php new file mode 100644 index 0000000..9681d7e --- /dev/null +++ b/src/Service/Mailer/Event/CreatedAdminEvent.php @@ -0,0 +1,32 @@ +account = $account; + $this->password = $password; + } + + /** + * @return Account + */ + public function getAccount(): Account + { + return $this->account; + } + + /** + * @return string + */ + public function getPassword(): string + { + return $this->password; + } +} diff --git a/src/Service/Mailer/Mailer.php b/src/Service/Mailer/Mailer.php new file mode 100644 index 0000000..d20e83e --- /dev/null +++ b/src/Service/Mailer/Mailer.php @@ -0,0 +1,43 @@ +setUsername("mainframe@esy-web.dev"); + $transport->setPassword("31,%,ArdrOA"); + } + $this->mailer = new \Symfony\Component\Mailer\Mailer($transport); + } + + public function send(string $address,string $addressName,string $subject,string $template,array $data) + { + $dest = new Address($address,$addressName); + $src = new Address("mainframe@esy-web.dev","Mainframe EsyWeb"); + $mail = new Email(); + $mail->subject($subject); + $mail->to($dest); + $mail->from($src); + $mail->generateMessageId(); + $mail->html($this->environment->render($template,array_merge([ + 'system' => [ + + ] + ],$data))); + $this->mailer->send($mail); + } +} diff --git a/src/Service/Mailer/MailerSubscriber.php b/src/Service/Mailer/MailerSubscriber.php new file mode 100644 index 0000000..430faa3 --- /dev/null +++ b/src/Service/Mailer/MailerSubscriber.php @@ -0,0 +1,25 @@ +getAccount(); + $password = $createdAdminEvent->getPassword(); + + dd($account,$password); + $this->mailer->send($account->getEmail(),$account->getUsername(),"[MainFrame] - Création d'un compte administrateur","mails/artemis/new_admin.twig",[ + 'account' => $account, + 'password' => $password, + ]); + } +} diff --git a/symfony.lock b/symfony.lock index 0e5369c..62c02e5 100644 --- a/symfony.lock +++ b/symfony.lock @@ -323,6 +323,15 @@ "templates/base.html.twig" ] }, + "symfony/uid": { + "version": "7.3", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "7.0", + "ref": "0df5844274d871b37fc3816c57a768ffc60a43a5" + } + }, "symfony/validator": { "version": "7.3", "recipe": { diff --git a/tests/Controller/HomeControllerTest.php b/tests/Controller/HomeControllerTest.php deleted file mode 100644 index 9a872b0..0000000 --- a/tests/Controller/HomeControllerTest.php +++ /dev/null @@ -1,22 +0,0 @@ -request('GET', '/'); - - // Validate a successful response and some content - $this->assertResponseIsSuccessful(); - - } -}