Search code examples
phplaravellaravel-5.1

How can I add a success flash message for the password reset functionality of Laravel?


I'm using Laravel 5.1 and the built-in auth functionality. When testing it, however, I noticed there is no "Success" message when a user fills out the forgotten password form, the page simply refreshes, although the form does work.

How can I set a success variable for the forgotten password tool? I can't find the method that controls this anywhere.

Thanks


Solution

  • If you’re using Laravel’s built-in password reset functionality, then it does have a success message. You can see it here: https://github.com/laravel/framework/blob/5.1/src/Illuminate/Foundation/Auth/ResetsPasswords.php#L95

    You merely need to listen for it in your view and display it if it’s there:

    @if(session('status'))
       <p class="alert alert-success">{{ session('status') }}</p>
    @endif
    

    This will display the default message, which is:

    Your password has been reset!

    If you want to change this message, just change the relevant line in resources/lang/en/passwords.php.