Laravel:如何更改默认登录错误消息:“这些凭据与我们的记录不匹配”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43053550/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel: How to change default login error message: 'these credentials do not match our records'
提问by S M Iftakhairul
I want to change the default login validation error message like:
我想更改默认登录验证错误消息,例如:
Username & Password doesn't match
instead of
代替
these credentials do not match our records
How to do this ?
这该怎么做 ?
回答by Alexey Mezenin
You can change this message to another one in this file:
您可以将此消息更改为该文件中的另一条消息:
resources/lang/en/auth.php
This is the line:
这是线路:
'failed' => 'These credentials do not match our records.',
回答by S M Iftakhairul
do one thing make new file message.php in lang folder then enter the error message in that and access in the controller and where you want to use like this in Authonticateduser.php
做一件事在 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'));
}
and you get the perfect mesege you want instead of system mesege and without any change in default message.
并且您将获得您想要的完美消息而不是系统消息,并且默认消息没有任何更改。