laravel / fortify

Backend controllers and scaffolding for Laravel authentication.
https://laravel.com/docs/fortify
MIT License
1.61k stars 294 forks source link

Undefined variable: request in reset-password.blade.php #57

Closed BlogProgWEB closed 4 years ago

BlogProgWEB commented 4 years ago

Description:

Undefined variable: request in reset-password.blade.php when I override view forgot-password

Steps To Reproduce:

Clean installation Laravel Framework 8.4.0 without any auth scaffolding.

Db migration and seed - it's ok!

Then:

composer require laravel/fortify

and php artisan vendor:publish...

php artisan migrate

It's ok!

Created in FortifyServiceProvider in boot() :

Fortify::requestPasswordResetLinkView(function () {  
  return view('admin.auth.forgot-password');  
});  

Fortify::resetPasswordView(function () {  
  return view('admin.auth.reset-password');  
});

And created views in view/admin/auth folder: forgot-password.blade.php

<form method="POST" action="/forgot-password">  
  @csrf  
  <input id="email" type="email" name="email" value="{{ old('email') }}" required>  
  <button type="submit">  
  {{ __('Send Password Reset Link') }}  
  </button>  
</form>

reset-password.blade.php

<form method="POST" action="/reset-password">  
  @csrf  
  <input type="hidden" name="token" value="{{ $request->route('token') }}">  
</form>

Then in browser /forgot-password Send Password Reset Link

From mail go to link /reset-password/543c9a...hash?email=admin%40example.com

I get

ErrorException
Undefined variable: request (View: ...\resources\views\admin\auth\reset-password.blade.php)`

It also doesn't work if I am using Jetstream and want to override the view forgot-password in JetstreamServiceProvider in boot() and sets any folder.

Even if I only specify this, I will not change anything else from a clean install (liveware).

Fortify::requestPasswordResetLinkView(static function () {
    return view('auth.forgot-password');
});
BlogProgWEB commented 4 years ago

Maybe this is not a wrong, and I didn't read something in the documentation or did I do it wrong?

driesvints commented 4 years ago

Docs are missing this:

Fortify::resetPasswordView(function ($request) {  
  return view('admin.auth.reset-password', ['request' => $request]);  
});

I'll send in a PR. Thanks.