【问题标题】:Laravel Password Reset Route not found未找到 Laravel 密码重置路径
【发布时间】:2016-06-09 15:39:52
【问题描述】:

我正在尝试在 laravel 5.2 中完成我的密码重置。一切正常,直到最后一部分。

当我输入我的电子邮件和新密码时,我收到了错误

RouteCollection.php 第 219 行中的 MethodNotAllowedHttpException:

这是我的路线

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');

这就是我的控制器的外观。

<?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 = '/';
}

这是表格

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

不知道为什么我会收到此错误并且我找不到解决方案。希望大家帮帮我

【问题讨论】:

    标签: php laravel laravel-5.2 password-recovery


    【解决方案1】:

    这是你的重置路线:

    Route::post('/password/reset', 'Auth\PasswordController@reset');
    

    但在你的表单中,你并没有发布到这条路线:

    <form action="" method="post">
    

    改变你的行动:

    <form action="/password/reset" method="post">
    

    【讨论】:

      【解决方案2】:

      设置表单动作为/password/reset

      【讨论】:

        猜你喜欢
        • 2021-02-21
        • 2014-07-24
        • 2016-01-23
        • 1970-01-01
        • 2014-08-10
        • 1970-01-01
        • 2018-12-30
        • 2020-06-11
        • 1970-01-01
        相关资源
        最近更新 更多