How to redirect user after password reset in laravel

Posted 5 years ago by Ryan Dhungel

Category: Laravel

Viewed 9221 times

Estimated read time: 2 minutes

When a user insert new password after requesting a password reset link, he is redirected to /home. In my app there was no home page so there was an error. I want to be able to redirect user to any page i want after successful password reset. What is the best way to do that?

In laravel, reset password rules are written in ResetPasswords.php It is located in vendor/laravel/framework/src/Illuminate/Auth/ResetsPasswords.php 


It uses use RedirectsUsers; as you can see it in line 13.


If you want you can see RedirectsUsers.php which is located in vendor/laravel/framework/src/Illuminate/Auth/RedirectsUsers.php as you can see it redirects users to home by default.


return property_exists($this, 'redirectTo') ? $this->redirectTo : '/home';


The best solution here is to declare a variable in PasswordController.php


It is located in app/Http/Controllers/Auth/PasswordController.php


In PasswordController simply put the code below and modify the way you want


protected $redirectTo = '/pagename';


Replace pagename with the actual page name you want to redirect users after they successfully reset the password


This is how my PasswordController looks like, Here i have redirected a user to forum page after password reset:


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

class PasswordController extends Controller

use ResetsPasswords;

/** * Where to redirect users after password reset. * * @var string */
protected $redirectTo = 'forum';

/** * Create a new password controller instance. * * @return void */
public function __construct()