我想更改默认的登录验证错误消息,如:
Username & Password doesn't match
而不是
these credentials do not match our records
怎么做?
答案 0 :(得分:10)
您可以在此文件中将此消息更改为另一个消息:
resources/lang/en/auth.php
这是一行:
'failed' => 'These credentials do not match our records.',
答案 1 :(得分:1)
在app/Http/controllers/Auth/LoginController
中添加以下代码:
protected function sendFailedLoginResponse(Request $request)
{
throw ValidationException::withMessages([
'username or password is incorrect!!!'
]);
}
在sendFailedLoginResponse
功能中,您可以将用户重定向到自定义页面或显示错误警报。
答案 2 :(得分:0)
做一件事在lang文件夹中创建新文件message.php然后在其中输入错误消息并在控制器中访问以及您要使用的位置,如下所示 在Authonticateduser.php中
protected function sendLoginResponse(Request $request) {
$request->session()->regenerate();
$this->clearLoginAttempts($request);
return $this->authenticated($request, $this->guard()->user())
? : redirect()->intended($this->redirectPath())->with('status', Lang::get('messege.login_success'));
}
你得到了你想要的完美mesege而不是系统mesege而且没有任何默认消息的变化。