diff --git a/composer.lock b/composer.lock index 886bb09..ce44b6f 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": "590b1692173c3fe783393e242af4753e", + "content-hash": "c53910010d80c77569e2b6c0828c9aa2", "packages": [ { "name": "doctrine/cache", @@ -3054,6 +3054,176 @@ ], "time": "2023-12-29T15:37:40+00:00" }, + { + "name": "symfony/http-client", + "version": "v7.0.10", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-client.git", + "reference": "3ae495c67ba9c3b504fecd070a6c28b4143088cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-client/zipball/3ae495c67ba9c3b504fecd070a6c28b4143088cf", + "reference": "3ae495c67ba9c3b504fecd070a6c28b4143088cf", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "psr/log": "^1|^2|^3", + "symfony/http-client-contracts": "^3.4.1", + "symfony/service-contracts": "^2.5|^3" + }, + "conflict": { + "php-http/discovery": "<1.15", + "symfony/http-foundation": "<6.4" + }, + "provide": { + "php-http/async-client-implementation": "*", + "php-http/client-implementation": "*", + "psr/http-client-implementation": "1.0", + "symfony/http-client-implementation": "3.0" + }, + "require-dev": { + "amphp/amp": "^2.5", + "amphp/http-client": "^4.2.1", + "amphp/http-tunnel": "^1.0", + "amphp/socket": "^1.1", + "guzzlehttp/promises": "^1.4|^2.0", + "nyholm/psr7": "^1.0", + "php-http/httplug": "^1.0|^2.0", + "psr/http-client": "^1.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/messenger": "^6.4|^7.0", + "symfony/process": "^6.4|^7.0", + "symfony/stopwatch": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpClient\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides powerful methods to fetch HTTP resources synchronously or asynchronously", + "homepage": "https://symfony.com", + "keywords": [ + "http" + ], + "support": { + "source": "https://github.com/symfony/http-client/tree/v7.0.10" + }, + "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-07-17T06:06:58+00:00" + }, + { + "name": "symfony/http-client-contracts", + "version": "v3.5.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-client-contracts.git", + "reference": "ee8d807ab20fcb51267fdace50fbe3494c31e645" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/ee8d807ab20fcb51267fdace50fbe3494c31e645", + "reference": "ee8d807ab20fcb51267fdace50fbe3494c31e645", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.5-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\HttpClient\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to HTTP clients", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/http-client-contracts/tree/v3.5.2" + }, + "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-12-07T08:49:48+00:00" + }, { "name": "symfony/http-foundation", "version": "v7.0.0", diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 4527a68..c5c4111 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -7,31 +7,39 @@ use App\Form\RegistrationType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; use Symfony\Component\Routing\Annotation\Route; use Doctrine\ORM\EntityManagerInterface; - class RegistrationController extends AbstractController { private $entityManager; + private $passwordHasher; // Correction du nom de la variable - public function __construct(EntityManagerInterface $entityManager) // Injection du service EntityManagerInterface + public function __construct(EntityManagerInterface $entityManager, UserPasswordHasherInterface $passwordHasher) // Correction ici { $this->entityManager = $entityManager; + $this->passwordHasher = $passwordHasher; } + #[Route('/registration', name: 'app_registration')] - public function register (Request $request): Response + public function register(Request $request): Response { $user = new User(); $form = $this->createForm(RegistrationType::class, $user); - $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - // Utilisation de l'EntityManager injecté + // Hacher le mot de passe avant de persister l'utilisateur + $plainPassword = $user->getPassword(); // Récupération du mot de passe brut + $hashedPassword = $this->passwordHasher->hashPassword($user, $plainPassword); // Hachage du mot de passe + $user->setPassword($hashedPassword); // Remplacer le mot de passe brut par le mot de passe haché + + // Persist de l'utilisateur haché $this->entityManager->persist($user); $this->entityManager->flush(); + // Message flash de succès $this->addFlash('success', 'Votre compte a été créé avec succès !'); return $this->redirectToRoute('home'); } @@ -40,5 +48,4 @@ class RegistrationController extends AbstractController 'form' => $form->createView(), ]); } - } diff --git a/src/Entity/User.php b/src/Entity/User.php index 30dbd37..5761b7c 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -4,9 +4,12 @@ namespace App\Entity; use App\Repository\UserRepository; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; +use Symfony\Component\Security\Core\User\UserInterface; + #[ORM\Entity(repositoryClass: UserRepository::class)] -class User +class User implements UserInterface, PasswordAuthenticatedUserInterface { #[ORM\Id] #[ORM\GeneratedValue] @@ -92,4 +95,24 @@ class User return $this; } + + public function getSalt(): ?string + { + return null; + } + + public function getRoles(): array + { + // TODO: Implement getRoles() method. + } + + public function eraseCredentials(): void + { + // TODO: Implement eraseCredentials() method. + } + + public function getUserIdentifier(): string + { + // TODO: Implement getUserIdentifier() method. + } } diff --git a/src/services/GoogleService.php b/src/services/GoogleService.php index aa04fd1..293227c 100644 --- a/src/services/GoogleService.php +++ b/src/services/GoogleService.php @@ -23,9 +23,10 @@ class GoogleBooksService ], ]); + // Convertir la réponse JSON en tableau PHP $dataArray = $response->toArray(); - dump($dataArray); + return $dataArray; } }