### Install ResetPasswordBundle Source: https://github.com/symfonycasts/reset-password-bundle/blob/main/README.md Use Composer to add the bundle to your Symfony project dependencies. ```bash composer require symfonycasts/reset-password-bundle ``` -------------------------------- ### Initialize ResetPasswordBundle via MakerBundle Source: https://github.com/symfonycasts/reset-password-bundle/blob/main/README.md Execute the Symfony console command to automatically generate configuration, templates, controllers, and entities. ```bash bin/console make:reset-password ``` -------------------------------- ### Configure Reset Password Bundle Source: https://github.com/symfonycasts/reset-password-bundle/blob/main/README.md Set bundle parameters in YAML or PHP configuration files. ```yaml symfonycasts_reset_password: request_password_repository: App\Repository\ResetPasswordRequestRepository lifetime: 3600 throttle_limit: 3600 enable_garbage_collection: true ``` ```php use App\Repository\ResetPasswordRequestRepository; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { $containerConfigurator->extension('symfonycasts_reset_password', [ 'request_password_repository' => ResetPasswordRequestRepository::class, 'lifetime' => 3600, 'throttle_limit' => 3600, 'enable_garbage_collection' => true, ]); }; ``` -------------------------------- ### Configure Production Routing URI Source: https://github.com/symfonycasts/reset-password-bundle/blob/main/README.md Define the default URI for production to ensure correct email links. ```yaml # config/packages/routing.yaml when@prod: framework: router: # ... default_uri: '' ``` ```php if ($containerConfigurator->env() === 'prod') { $containerConfigurator->extension('framework', [ 'router' => [ # ... 'default_uri' => '' ], ]); } ``` -------------------------------- ### Configure Reset Password Bundle Source: https://github.com/symfonycasts/reset-password-bundle/wiki/Confguration-Reference The complete configuration structure for the symfonycasts_reset_password bundle in YAML format. ```yaml symfonycasts_reset_password: request_password_repository: App\Repository\PasswordResetRequestRepository lifetime: 3600 throttle_limit: 3600 enable_garbage_collection: true ``` -------------------------------- ### Remove reset password requests for a user Source: https://github.com/symfonycasts/reset-password-bundle/blob/main/README.md Use the removeRequests method from the repository to clear all password reset requests for a user, typically after an email address change. ```php // ProfileController #[Route(path: '/profile/{id}', name: 'app_update_profile', methods: ['GET', 'POST'])] public function profile(Request $request, User $user, ResetPasswordRequestRepositoryInterface $repository): Response { $originalEmail = $user->getEmail(); $form = $this->createFormBuilder($user) ->add('email', EmailType::class) ->add('save', SubmitType::class, ['label' => 'Save Profile']) ->getForm() ; $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { if ($originalEmail !== $user->getEmail()) { // The user changed their email address. // Remove any old reset requests for the user. $repository->removeRequests($user); } // Persist the user object and redirect... } return $this->render('profile.html.twig', ['form' => $form]); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.