Forgot password function fosuserbundle

smugford picture smugford · Nov 25, 2013 · Viewed 30k times · Source

I have been googling for a couple hours now and cannot find any information on how to implement the "Forgot Password" functionality in FOSUserBundle

Is this part of the bundle or is it something I have to create myself.

Answer

lenybernard picture lenybernard · Nov 30, 2013

Actually it is weird that you didn't find anything about it, you probably didn't search with good terms (maybe reset instead of forgot). Anyway it's a pretty simple process. You probably read the github documentation, it's explained there (Step 6) that you have to import the routing.xml file and furthermore this route :

fos_user_resetting:
    resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
    prefix: /resetting

You just have to add a link in your template with the fos_user_resetting_request route :

<a href="{{ path('fos_user_resetting_request') }}">Forgot password ?</a>

Then a click on this link will lead the user to a reset form which will ask the user email and send them an email with a security token in the link to the password edit form.

If you want to customize the render, read these docs :

Does it help you? Good luck!