diff --git a/.vscode/settings.json b/.vscode/settings.json index e14c89a..81bb8d7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,7 @@ { "editor.fontSize": 14, "php-cs-fixer.executablePath": "${workspaceFolder}/vendor/bin/php-cs-fixer", - "php-cs-fixer.onsave": true, // Active l'exécution à la sauvegarde - "php-cs-fixer.rules": null // Null pour utiliser les règles définies dans .php-cs-fixer.dist.php + "php-cs-fixer.onsave": true, + "php-cs-fixer.rules": "@Symfony", + "php-cs-fixer.config": ".php-cs-fixer.dist.php" } \ No newline at end of file diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index f40cb0f..8fec84e 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -68,15 +68,17 @@ class UserController extends AbstractController if (!$user) { return $this->redirectToRoute('app_admin_user'); } - $oldpassword=$user->getPassword(); + $hashedPassword = $user->getPassword(); $form = $this->createForm(UserType::class, $user, ['mode' => 'update']); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $user = $form->getData(); - $hashedPassword = $passwordHasher->hashPassword( - $user, - $user->getPassword() - ); + if (!$user->getPassword()) { + $hashedPassword = $passwordHasher->hashPassword( + $user, + $user->getPassword() + ); + } $user->setPassword($hashedPassword); $em->persist($user); diff --git a/src/Entity/User.php b/src/Entity/User.php index 4645fee..ef2f3ab 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -110,7 +110,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface return $this->password; } - public function setPassword(string $password): static + public function setPassword(?string $password): static { $this->password = $password;