Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect after sending password reset link in Laravel 5.1?

How can set a redirect path after sending the password reset link?

In the ResetsPaswords trait is this code:

switch ($response) {
    case Password::RESET_LINK_SENT:
       return redirect()->back()->with('status', trans($response));

    case Password::INVALID_USER:
       return redirect()->back()->withErrors(['email' => trans($response)]);
}

But I don't want to change the vendor files. Is there another way?

like image 951
Jeton Thaçi Avatar asked Dec 09 '22 01:12

Jeton Thaçi


1 Answers

You can do this by adding protected $redirectTo = '/dashboard'; to your PasswordController.

So your controller would look like this:

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;

class PasswordController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Password Reset Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling password reset requests
    | and uses a simple trait to include this behavior. You're free to
    | explore this trait and override any methods you wish to tweak.
    |
    */

    use ResetsPasswords;

    protected $redirectTo = '/dashboard';

    //The rest of the controller below this...

And you can customise the route by changing /dashboard to where you wish to redirect them.

You should check out the docs for more info.

like image 105
James Avatar answered Dec 11 '22 10:12

James