2016-12-06 126 views
2

我是Laravel的新手,我在使用4.2版本的系統上做了一些測試。我正試圖按照Documentation重設密碼。到目前爲止,我可以發佈我的電子郵件進行密碼重置,並在我的電子郵件中獲得令牌。帶密碼的密碼重置laravel 4.2

當我從與令牌電子郵件打開URL我得到這個錯誤:

exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException'

的網址是:http://example.com/reset/20e2535a11f7c88d1132c55c752a3a8569adbf5f

這是我的路線

Route::get('/password', ['uses' => '[email protected]']); 
Route::get('/reset', ['uses' => '[email protected]']); 

這是RemindersController

public function getReset($token = null) 
{ 
    if (is_null($token)) App::abort(404); 

    return View::make('site.reset')->with('token', $token); 
} 

而且從文檔的

<form action="{{ action('[email protected]') }}" 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> 

我理解錯誤..它是說,路徑/文件中找不到但它的存在..如果

+0

這裏看看http://stackoverflow.com/questions/29241969/reset-password-without-token-in-laravel-4-2 – Blueblazer172

+0

@ Blueblazer172我想用令牌.. – VLS

+0

然後看[這裏](https://laracasts.com/discuss/channels/laravel/get-a -password-reset-token/answers/90648)或[here](htt p://stackoverflow.com/a/26362002/5930557) – Blueblazer172

回答

1
在HTML表單

,有action()方法稱爲[email protected]

<form action="{{ action('[email protected]') }}" 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' => '[email protected]']); 

到:

Route::post('/reset', ['uses' => '[email protected]']); 

我想你可以用這種方式。它也許更好:

Route::match(['GET','POST'], ['uses' => '[email protected]']); 



更新:路線也應該有它token因爲URL是/reset/token

Route::get('/reset/{token}', ['uses' => '[email protected]']); 
+0

但是我的reset.blade在'/ site /'不在/'auth/' – VLS

+0

@VLS嘗試將其更改爲身份驗證,然後再試一次 – Blueblazer172

+0

我只是爲了測試..但我不想在那裏。 – VLS

1

檢查您的默認控制器或默認形式安全控制器不加載的地方,它不會不覆蓋「復位」的路線,使用命令行和類型得到您的應用程序目錄:

php artisan routes 

這應該告訴你,如果你的路線被註冊到控制器/動作。

+0

我沒有權限訪問ssh終端並且無法運行命令 – VLS