5252use Symfony \Component \HttpFoundation \Response ;
5353use Symfony \Component \Mailer \MailerInterface ;
5454use Symfony \Component \Mime \Address ;
55- use Symfony \Component \PasswordHasher \Hasher \UserPasswordHasherInterface ;
5655use Symfony \Component \Routing \Attribute \Route ;
5756use Symfony \Component \Routing \RouterInterface ;
5857use Symfony \Component \Security \Core \User \UserInterface ;
@@ -291,7 +290,8 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
291290 $ formClassDetails = $ this ->generateFormClass (
292291 $ userClassNameDetails ,
293292 $ generator ,
294- $ usernameField
293+ $ usernameField ,
294+ $ this ->passwordField
295295 );
296296
297297 // 2) Generate the controller
@@ -307,7 +307,6 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
307307 Request::class,
308308 Response::class,
309309 Route::class,
310- UserPasswordHasherInterface::class,
311310 EntityManagerInterface::class,
312311 ]);
313312
@@ -355,7 +354,6 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
355354 'route_name ' => 'app_register ' ,
356355 'form_class_name ' => $ formClassDetails ->getShortName (),
357356 'user_class_name ' => $ userClassNameDetails ->getShortName (),
358- 'password_field ' => $ this ->passwordField ,
359357 'redirect_route_name ' => $ this ->redirectRouteName ?? null ,
360358 'translator_available ' => $ isTranslatorAvailable ,
361359 ],
@@ -545,7 +543,7 @@ public function configureDependencies(DependencyBuilder $dependencies): void
545543 );
546544 }
547545
548- private function generateFormClass (ClassNameDetails $ userClassDetails , Generator $ generator , string $ usernameField ): ClassNameDetails
546+ private function generateFormClass (ClassNameDetails $ userClassDetails , Generator $ generator , string $ usernameField, string $ passwordField ): ClassNameDetails
549547 {
550548 $ formClassDetails = $ generator ->createClassNameDetails (
551549 'RegistrationFormType ' ,
@@ -568,9 +566,8 @@ private function generateFormClass(ClassNameDetails $userClassDetails, Generator
568566 'plainPassword ' => [
569567 'type ' => PasswordType::class,
570568 'options_code ' => <<<EOF
571- // instead of being set onto the object directly,
572- // this is read and encoded in the controller
573569 'mapped' => false,
570+ 'hash_property_path' => ' $ passwordField',
574571 'attr' => ['autocomplete' => 'new-password'],
575572 'constraints' => [
576573 new NotBlank([
0 commit comments