【问题标题】:Reset user passwords in Laravel framework在 Laravel 框架中重置用户密码
【发布时间】:2014-12-09 07:31:47
【问题描述】:

我正在尝试根据这个实现密码提醒: http://laravel.com/docs/4.2/security

我使用了工匠命令:

php artisan auth:reminders-table

php artisan migrate

并将其添加到我的路线中:

Route::controller('password', 'RemindersController');
Route::get('forgotpassword', 'RemindersController@getRemind');

所以现在当我转到此页面时:myapp/forgotpassword 我得到了password.remind 视图

代码如下:

<?php include_once(app_path()."/includes/header.php"); ?>

<form action="{{ action('RemindersController@postRemind') }}" method="POST">
<input type="email" name="email">
<input type="submit" value="Send Reminder">
</form>

<?php include_once(app_path()."/includes/footer.php"); ?>

当我到达此页面并单击提交表单时,我收到NotFoundHttpException 错误,如果我将表单中的操作更改为其他功能,也会发生此错误。我的路线有问题吗?还是使用我从控制器调用函数的语法?

谢谢

【问题讨论】:

    标签: laravel laravel-4 laravel-routing


    【解决方案1】:

    你应该改变:

    Route::get('forgotpassword', 'RemindersController@getRemind');
    

    进入

    Route::post('forgotpassword', 'RemindersController@getRemind');
    

    那是因为你使用 POST 方法来发送表单。

    但您似乎对 GET 和 POST 使用相同的控制器方法,因此在这种情况下您可能需要:

    Route::match(['GET','POST'], 'forgotpassword', 'RemindersController@getRemind');
    

    【讨论】:

    • 我编辑了表单中的一个错误,而不是 action('RemindersController@getRemind' 它应该是 action('RemindersController@postRemind ,它在同一个控制器中是不同的函数。获取提醒功能只有这一行:return View::make('password.remind'); 并改变从 get 到 post 的路线给我一个methotnotallowed错误
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-28
    • 1970-01-01
    • 2019-06-02
    • 2020-01-31
    • 2016-01-05
    • 2018-07-20
    相关资源
    最近更新 更多