I am following this tutorial on setting up authentication with Laravel and I am mostly there apart from one bit.
When I make a request for a password reset I get an email sent out to me and if I click on the link in the email I get to a form which I then fill in correctly and expect to be redirected back to /dashboard, however this never happens and instead it redirects to /home.
I can't provide any code as everything is done behind the scenes by Laravel. Any help appreciated : ).
This is because you are expecting the reset password controller to redirect you to /dashboard
on a successful reset. Maybe I'm wrong, but I can't see anywhere in the code where that is specified (based, as you say, on a fresh Laravel install).
To demonstrate this, let's follow the code:
By default in a fresh Laravel installation you get a PasswordController
in your app/Http/Controllers/Auth/
directory. On line 21 of that file, it 'includes' the ResetsPasswords
trait. So let's look at that trait.
As you can see, in the postReset
method (which is the method that is run to do the final actual password reset), on line 95 the redirect location is deferred to redirectPath
, and as you can see, on line 131 the code specifically forwards the user to /home
if no redirectPath
or redirectTo
property exists on the controller.
So, to manually set the redirect location, just set protected $redirectPath = '/dashboard';
in your Http\Controllers\Auth\PasswordController
class.
But also, on the page you linked to, see the section "After resetting passwords" for the official docs on this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With