Laravel 5.4 PHP 5.6 XAMPP localhost
I have set up a basic laravel app, I ran command:
php artisan make:auth
to create the auth scaffolding
then ran command
php artisan migrate
to update the databases and create necessary tables
I am able to register users, log them in , and log out. However none of the other authentication stuff works.
Here is the error I receive when I try localhost/password/email
(1/1) MethodNotAllowedHttpException
in RouteCollection.php (line 251)
at RouteCollection->methodNotAllowed(array('POST'))
in RouteCollection.php (line 238)
at RouteCollection->getRouteForMethods(object(Request), array('POST'))
in RouteCollection.php (line 176)
at RouteCollection->match(object(Request))
in Router.php (line 546)
at Router->findRoute(object(Request))
in Router.php (line 525)
at Router->dispatchToRoute(object(Request))
in Router.php (line 511)
at Router->dispatch(object(Request))
in Kernel.php (line 176)
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
in Pipeline.php (line 30)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in TransformsRequest.php (line 30)
at TransformsRequest->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in TransformsRequest.php (line 30)
at TransformsRequest->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in ValidatePostSize.php (line 27)
at ValidatePostSize->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in CheckForMaintenanceMode.php (line 46)
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in Pipeline.php (line 102)
at Pipeline->then(object(Closure))
in Kernel.php (line 151)
at Kernel->sendRequestThroughRouter(object(Request))
in Kernel.php (line 116)
at Kernel->handle(object(Request))
in index.php (line 54)
But the method not allowed thing makes no sense to me since my Router.php is this:
// Password Reset Routes...
$this->get('password/reset',
'Auth\ForgotPasswordController@showLinkRequestForm')-
>name('password.request');
$this->post('password/email',
'Auth\ForgotPasswordController@sendResetLinkEmail')-
>name('password.email');
$this->get('password/reset/{token}',
'Auth\ResetPasswordController@showResetForm')->name('password.reset');
$this->post('password/reset', 'Auth\ResetPasswordController@reset');
And my email.blade.php
...
<form class="form-horizontal" method="POST" action="{{
route('password.email') }}">
{{ csrf_field() }}
...
Notice the method="POST"
And my web.php has the "Auth:routes();"
Can someone please help?
The docs online make it sound as if running php artisan make:auth is all you need for proper authentication flow, but what if your user forgets their password?
Another thing, laravel documentation reads: To get started, verify that your App\User model implements the Illuminate\Contracts\Auth\CanResetPassword contract.
Here is my model User.php
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
class User extends Authenticatable
{
use Notifiable;
use CanResetPassword;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPasswordNotification($token));
}
}