2017-10-16 130 views
1

Laravel 5.4 PHP 5.6 XAMPP本地主机laravel 5.4忘记密码

我已经建立了一个基本的laravel的应用程序,我跑的命令:

php artisan make:auth 

创建AUTH脚手架

然后跑命令

php artisan migrate 

更新th e数据库并创建必要的表格

我能够注册用户,登录他们并注销。 然而,没有其他认证的东西工作。

这是我收到的错误,当我尝试 本地主机/密码/电子邮件

(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) 

但方法不被允许的事情是没有意义的我,因为我Router.php是这样的:

// Password Reset Routes... 
    $this->get('password/reset', 
'Auth\[email protected]')- 
>name('password.request'); 
    $this->post('password/email', 
'Auth\[email protected]')- 
>name('password.email'); 
    $this->get('password/reset/{token}', 
'Auth\[email protected]')->name('password.reset'); 
    $this->post('password/reset', 'Auth\[email protected]'); 

而且我email.blade.php

... 
<form class="form-horizontal" method="POST" action="{{ 
route('password.email') }}"> 
        {{ csrf_field() }} 
... 

通知的方法= “POST”

而我的web.php有“Auth:routes();”

有人可以帮忙吗?

文档在线使其听起来好像运行php artisan make:auth就是您需要的适当身份验证流程,但如果您的用户忘记了密码呢?

另一件事,拉拉维尔文档阅读: 要开始,请验证您的应用程序\用户模型实现 Illuminate \ Contracts \ Auth \ CanResetPassword合同。

这里是我的模型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)); 
} 
} 
+0

你有什么设置为XAMPP的根目录? –

+0

标准C:/ xampp/htdocs/mysite – gabefiftyone

+0

您的根目录需要是laravel项目中的公共目录,然后您的所有路由应该开始正常工作 –

回答

0

当您 “尝试” localhost/password/email您使用GET调用的URL。此路线(/password/email)已在您的router.php中注册为POST路线,这就是您遇到错误的原因。

重置密码的URL应为/password/reset

另一件事,laravel文档显示:要开始,请验证您的App \ User模型实现Illuminate \ Contracts \ Auth \ CanResetPassword合同。

它在哪里说的? https://laravel.com/docs/5.4/authentication

+1

此处:https://laravel.com/docs/5.4/passwords – gabefiftyone