在视图中的laravel 5.1中单击内置身份验证后,如何输出密码重置按钮后的状态消息?
代码位于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)]); } }
检查案例密码:PASSWORD_RESET:状态是负责消息的变量.而且这个变量的值是
"我们已通过电子邮件发送密码重置链接!"
使用下面的代码输出上面的状态消息
{{ Session::get('status') }}
或者你可以使用
{{ Session::has('status') }}
它会返回值1.
要更改状态消息的值,只需转到
/resources/lang/en/passwords.php
下面是passwords.php的代码
'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.", ];
希望这对你有所帮助.