Rab*_*bit 4 authentication passwords reset laravel-5
在视图中的laravel 5.1中单击内置身份验证后,如何输出密码重置按钮后的状态消息?
Rab*_*bit 10
代码位于Illuminate\Foundation\Auth\ResetsPasswords中
在函数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)]);
}
}
Run Code Online (Sandbox Code Playgroud)
检查案例密码:PASSWORD_RESET:状态是负责消息的变量.而且这个变量的值是
"我们已通过电子邮件发送密码重置链接!"
使用下面的代码输出上面的状态消息
{{ Session::get('status') }}
Run Code Online (Sandbox Code Playgroud)
或者你可以使用
{{ Session::has('status') }}
Run Code Online (Sandbox Code Playgroud)
它会返回值1.
要更改状态消息的值,只需转到
/resources/lang/en/passwords.php
下面是passwords.php的代码
<?php
return [
/*
|--------------------------------------------------------------------------
| Password Reminder Language Lines
|--------------------------------------------------------------------------
|
| The following language lines are the default lines which match reasons
| that are given by the password broker for a password update attempt
| has failed, such as for an invalid token or invalid new password.
|
*/
'password' => 'Passwords must be at least six characters and match the confirmation.',
'reset' => 'Your password has been reset!',
'sent' => 'We have e-mailed your password reset link!',
'token' => 'This password reset token is invalid.',
'user' => "We can't find a user with that e-mail address.",
];
Run Code Online (Sandbox Code Playgroud)
希望这对你有所帮助.
| 归档时间: |
|
| 查看次数: |
3232 次 |
| 最近记录: |