Reset user passwords in Laravel framework

偶尔善良 提交于 2020-01-17 12:28:05

问题


I'm trying to implement the password reminder according to this: http://laravel.com/docs/4.2/security

I used the artisan commands :

php artisan auth:reminders-table

php artisan migrate

and added this to my routes:

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

so now when I go to this page : myapp/forgotpassword I get the password.remind view

which has the following code:

<?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"); ?>

when i get to this page and i click on the submit form i get a NotFoundHttpException error, this error happens also if i change the action in the form to other functions.. is there something wrong with my routes? or with my syntax for calling a function from a controller?

Thx


回答1:


You should change:

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

into

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

That's because you use POST method to send form.

But it seems you use the same controller method both for GET and POST, so you probably need in this case:

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


来源:https://stackoverflow.com/questions/26361941/reset-user-passwords-in-laravel-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!