@@ -226,13 +226,42 @@ After configuring the correct algorithm, you can use the
226226 throw new \Exception('Bad credentials, cannot delete this user.');
227227 }
228228
229+ Reset Password
230+ --------------
231+
232+ Using `MakerBundle `_ and `SymfonyCastsResetPasswordBundle `_, you can create
233+ a secure out of the box solution to handle forgotten passwords. First,
234+ install the SymfonyCastsResetPasswordBundle:
235+
236+ .. code-block :: terminal
237+
238+ $ composer require symfonycasts/reset-password-bundle
239+
240+ Then, use the ``make:reset-password `` command. This asks you a few
241+ questions about your app and generates all the files you need! After,
242+ you'll see a success message and a list of any other steps you need to do.
243+
244+ .. code-block :: terminal
245+
246+ $ php bin/console make:reset-password
247+
248+ .. tip ::
249+
250+ Starting in `MakerBundle `_: v1.57.0 - You can pass either ``--with-uuid `` or
251+ ``--with-ulid `` to ``make:reset-password ``. Leveraging Symfony's :doc: `Uid Component </components/uid >`,
252+ the entities will be generated with the ``id `` type as :ref: `Uuid <uuid >`
253+ or :ref: `Ulid <ulid >` instead of ``int ``.
254+
255+ You can customize the reset password bundle's behavior by updating the
256+ ``reset_password.yaml `` file. For more information on the configuration,
257+ check out the `SymfonyCastsResetPasswordBundle `_ guide.
258+
229259Injecting a Specific Password Hasher
230260~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
231261
232- In some cases, you might define a password hasher in your configuration that is
233- not linked to a user entity but is instead identified by a unique key.
234- For example, you might have a separate hasher for things like password recovery
235- codes.
262+ In some cases, you may define a password hasher in your configuration that is
263+ not tied to a user class. For example, you might use a separate hasher for
264+ password recovery codes or API tokens.
236265
237266With the following configuration:
238267
@@ -247,12 +276,12 @@ With the following configuration:
247276 main :
248277 # ...
249278
250- It is possible to inject the recovery_code password hasher into any service.
251- To do this, you can't rely on standard autowiring, as Symfony wouldn 't know
252- which specific hasher to provide.
279+ You can inject the `` recovery_code `` password hasher into any service. However,
280+ you can't rely on standard autowiring, as Symfony doesn 't know which specific
281+ hasher to provide.
253282
254- Instead, you can use the ``#[Target] `` attribute to request the hasher by its
255- configuration key::
283+ Instead, use the ``#[Target] `` attribute to explicitly request the hasher by
284+ its configuration key::
256285
257286 // src/Controller/HomepageController.php
258287 namespace App\Controller;
@@ -281,35 +310,9 @@ configuration key::
281310When injecting a specific hasher by its name, you should type-hint the generic
282311:class: `Symfony\\ Component\\ PasswordHasher\\ PasswordHasherInterface `.
283312
284- Reset Password
285- --------------
286-
287- Using `MakerBundle `_ and `SymfonyCastsResetPasswordBundle `_, you can create
288- a secure out of the box solution to handle forgotten passwords. First,
289- install the SymfonyCastsResetPasswordBundle:
290-
291- .. code-block :: terminal
292-
293- $ composer require symfonycasts/reset-password-bundle
294-
295- Then, use the ``make:reset-password `` command. This asks you a few
296- questions about your app and generates all the files you need! After,
297- you'll see a success message and a list of any other steps you need to do.
313+ .. versionadded :: 7.4
298314
299- .. code-block :: terminal
300-
301- $ php bin/console make:reset-password
302-
303- .. tip ::
304-
305- Starting in `MakerBundle `_: v1.57.0 - You can pass either ``--with-uuid `` or
306- ``--with-ulid `` to ``make:reset-password ``. Leveraging Symfony's :doc: `Uid Component </components/uid >`,
307- the entities will be generated with the ``id `` type as :ref: `Uuid <uuid >`
308- or :ref: `Ulid <ulid >` instead of ``int ``.
309-
310- You can customize the reset password bundle's behavior by updating the
311- ``reset_password.yaml `` file. For more information on the configuration,
312- check out the `SymfonyCastsResetPasswordBundle `_ guide.
315+ The feature to inject specific password hashers was introduced in Symfony 7.4.
313316
314317.. _security-password-migration :
315318
0 commit comments