使用令牌重置密码 laravel 4.2
Password reset laravel 4.2 with Token
我是 Laravel 的新手,我在使用 4.2 版的系统上进行了一些测试。我正在尝试按照 Documentation 进行密码重置。到目前为止,我能够 post 我的电子邮件用于重置密码,并且我在我的电子邮件中获得了令牌。
当我使用令牌从电子邮件中打开 URL 时,出现此错误:
exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException'
url是:http://example.com/reset/20e2535a11f7c88d1132c55c752a3a8569adbf5f
这是我的路线
Route::get('/password', ['uses' => 'RemindersController@getRemind']);
Route::get('/reset', ['uses' => 'RemindersController@getReset']);
这是在RemindersController
public function getReset($token = null)
{
if (is_null($token)) App::abort(404);
return View::make('site.reset')->with('token', $token);
}
以及来自文档
的表格
<form action="{{ action('RemindersController@postReset') }}" method="POST">
<input type="hidden" name="token" value="{{ $token }}">
<input type="email" name="email">
<input type="password" name="password">
<input type="password" name="password_confirmation">
<input type="submit" value="Reset Password">
</form>
我明白这个错误..它说 path/file 没有找到但它在那里..
检查您的默认控制器或默认安全控制器是否未在某处加载并且它不会覆盖 'reset' 路由,使用命令行进入您的应用程序目录并键入:
php artisan routes
这应该会显示您的路线是否已注册以及controller/action。
在您的 html 表单中,有一个名为 RemindersController@postReset
:
的 action()
方法
<form action="{{ action('RemindersController@postReset') }}" method="POST">
<input type="hidden" name="token" value="{{ $token }}">
<input type="email" name="email">
<input type="password" name="password">
<input type="password" name="password_confirmation">
<input type="submit" value="Reset Password">
</form>
但您的路线使用 GET
。你必须使用 POST
更改您的路线:
Route::get('/reset', ['uses' => 'RemindersController@getReset']);
至:
Route::post('/reset', ['uses' => 'RemindersController@getReset']);
我想你可以用这种方式。它可能更好:
Route::match(['GET','POST'], ['uses' => 'RemindersController@getRemind']);
更新: 路由也应该包含 token
因为 url 是 /reset/token
:
Route::get('/reset/{token}', ['uses' => 'RemindersController@getReset']);
我是 Laravel 的新手,我在使用 4.2 版的系统上进行了一些测试。我正在尝试按照 Documentation 进行密码重置。到目前为止,我能够 post 我的电子邮件用于重置密码,并且我在我的电子邮件中获得了令牌。
当我使用令牌从电子邮件中打开 URL 时,出现此错误:
exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException'
url是:http://example.com/reset/20e2535a11f7c88d1132c55c752a3a8569adbf5f
这是我的路线
Route::get('/password', ['uses' => 'RemindersController@getRemind']);
Route::get('/reset', ['uses' => 'RemindersController@getReset']);
这是在RemindersController
public function getReset($token = null)
{
if (is_null($token)) App::abort(404);
return View::make('site.reset')->with('token', $token);
}
以及来自文档
的表格<form action="{{ action('RemindersController@postReset') }}" method="POST">
<input type="hidden" name="token" value="{{ $token }}">
<input type="email" name="email">
<input type="password" name="password">
<input type="password" name="password_confirmation">
<input type="submit" value="Reset Password">
</form>
我明白这个错误..它说 path/file 没有找到但它在那里..
检查您的默认控制器或默认安全控制器是否未在某处加载并且它不会覆盖 'reset' 路由,使用命令行进入您的应用程序目录并键入:
php artisan routes
这应该会显示您的路线是否已注册以及controller/action。
在您的 html 表单中,有一个名为 RemindersController@postReset
:
action()
方法
<form action="{{ action('RemindersController@postReset') }}" method="POST">
<input type="hidden" name="token" value="{{ $token }}">
<input type="email" name="email">
<input type="password" name="password">
<input type="password" name="password_confirmation">
<input type="submit" value="Reset Password">
</form>
但您的路线使用 GET
。你必须使用 POST
更改您的路线:
Route::get('/reset', ['uses' => 'RemindersController@getReset']);
至:
Route::post('/reset', ['uses' => 'RemindersController@getReset']);
我想你可以用这种方式。它可能更好:
Route::match(['GET','POST'], ['uses' => 'RemindersController@getRemind']);
更新: 路由也应该包含 token
因为 url 是 /reset/token
:
Route::get('/reset/{token}', ['uses' => 'RemindersController@getReset']);