Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 Auth - How to output the status message after email sent from password reset page

How to output the status message after password reset button is click in built in auth in laravel 5.1 on your view?

like image 729
Rabb-bit Avatar asked Dec 18 '22 21:12

Rabb-bit


1 Answers

The code is in Illuminate\Foundation\Auth\ResetsPasswords

at function postReset.

public function postReset(Request $request)
    {
        $this->validate($request, [
            'token' => 'required',
            'email' => 'required|email',
            'password' => 'required|confirmed|min:6',
        ]);

        $credentials = $request->only(
            'email', 'password', 'password_confirmation', 'token'
        );

        $response = Password::reset($credentials, function ($user, $password) {
            $this->resetPassword($user, $password);
        });

        switch ($response) {
            case Password::PASSWORD_RESET:
                return redirect($this->redirectPath())->with('status', trans($response));

            default:
                return redirect()->back()
                            ->withInput($request->only('email'))
                            ->withErrors(['email' => trans($response)]);
        }
    }

Check the case Password:PASSWORD_RESET: the status is the variable responsible for the message. and the value of this variable is

"We have e-mailed your password reset link!"

use the code below to output the status message above

{{ Session::get('status') }}

or you can use

{{ Session::has('status') }} 

and it will return you a value of 1.

To change the value of the status message just go to

/resources/lang/en/passwords.php

below is the code of the passwords.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Password Reminder Language Lines
    |--------------------------------------------------------------------------
    |
    | The following language lines are the default lines which match reasons
    | that are given by the password broker for a password update attempt
    | has failed, such as for an invalid token or invalid new password.
    |
    */

    'password' => 'Passwords must be at least six characters and match the confirmation.',
    'reset' => 'Your password has been reset!',
    'sent' => 'We have e-mailed your password reset link!',
    'token' => 'This password reset token is invalid.',
    'user' => "We can't find a user with that e-mail address.",

];

Hope this helps you.

like image 69
Rabb-bit Avatar answered May 12 '23 04:05

Rabb-bit