[英]Laravel 5.1, In password reset form no value in email field
我在Laravel 5.1中的密碼重置過程中遇到一些問題
生產步驟:
在該表格中,我使用了相同的表格,在此處提供https://laravel.com/docs/5.1/authentication#resetting-passwords “示例密碼重置表格”
我只是注意到隱藏的電子郵件字段沒有填充
<input type="email" name="email" value="{{ old('email') }}">
當我使用laravel的默認方法時,它會調用-
public function getReset($token = null)
{
if (is_null($token)) {
throw new NotFoundHttpException;
}
return view('auth.reset')->with('token', $token);
}
顯然,沒有傳遞給查看的電子郵件變量,並且在提交后命中了postReset
public function postReset(Request $request)
{
$this->validate($request, [
'token' => 'required',
'email' => 'required|email',
'password' => 'required|confirmed|min:6',
]);
$credentials = $request->only(
'email', 'password', 'password_confirmation', 'token'
);
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case Password::PASSWORD_RESET:
return redirect($this->redirectPath())->with('status', trans($response));
default:
return redirect()->back()
->withInput($request->only('email'))
->withErrors(['email' => trans($response)]);
}
}
所以主要問題是當我使用laravel 5.1文檔中的默認指南時,電子郵件字段沒有填充。
我應該傳遞令牌之類的電子郵件參數,還是丟失某些東西?
只需在Model User.php
添加以下代碼
/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPasswordNotification($token.'/'.$this->email));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.