找不到 Laravel 密码重置路由
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37730521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel Password Reset Route not found
提问by Nicolas
I'm trying to complete my password reset in laravel 5.2. Everything works, up until the last part.
我正在尝试在 laravel 5.2 中完成我的密码重置。一切正常,直到最后一部分。
When I enter my email and the new password I receive the error
当我输入我的电子邮件和新密码时,我收到错误
MethodNotAllowedHttpException in RouteCollection.php line 219:
RouteCollection.php 第 219 行中的 MethodNotAllowedHttpException:
Here are my routes
这是我的路线
Route::get('/password/reset/email', 'Auth\PasswordController@getEmail');
Route::post('/password/reset/email', 'Auth\PasswordController@postEmail');
Route::get('/password/email', 'Auth\PasswordController@sendResetLinkEmail');
Route::get('/password/reset/{token}', 'Auth\PasswordController@showResetForm');
Route::post('/password/reset', 'Auth\PasswordController@reset');
And this is how my controllerlooks.
这就是我的控制器的外观。
<?php
namespace App\Http\Controllers\Auth;
use View;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class PasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Create a new password controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
public function getSendResetLinkEmailSuccessResponse()
{
return View::make('auth.passwordSent');
}
protected $redirectPath = '/';
}
Here's the Form:
这是表格:
<form action="" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<label for="login-form-email">E-mail</label>
<input type="email" name="email" id="email" class="form-control" tabindex="1" placeholder="Email" value="{{ old('email') }}">
</div>
<div class="form-group">
<label for="login-form-password">New password</label>
<input type="password" class="form-control" name="password" id="login-form-password" tabindex="2" placeholder="Password" tabindex="4">
</div><!-- /.form-group -->
<div class="form-group">
<label for="login-form-password-retype">Confirm new password</label>
<input type="password" class="form-control" name="password_confirmation" id="login-form-password-retype" tabindex="3" placeholder="Confirm password">
</div><!-- /.form-group -->
<div class="form-group">
<input type="submit" class="btn btn-primary pull-right" name="reset-confirm" id="reset-confirm" tabindex="4" value="Reset Password">
</div>
</form>
Not sure why I'm getting this error and I can't find a solution to it. Hope you guys can help me out
不知道为什么我会收到这个错误,我找不到解决办法。希望你们能帮帮我
回答by jszobody
This is your reset route:
这是您的重置路线:
Route::post('/password/reset', 'Auth\PasswordController@reset');
And yet in your form, you aren't posting to this route:
然而在你的表单中,你没有发布到这条路线:
<form action="" method="post">
Change your action:
改变你的行动:
<form action="/password/reset" method="post">
回答by Laravel User
Set action of form to /password/reset
将表单的操作设置为 /password/reset