you could change the laravel lang file in /resources/lang/en/auth.php and you should see
'failed' => 'These credentials do not match our records.',
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I am trying to return my own error as json on failed login via ajax but I have a small problem
if (Auth::attempt(['email' => request('email'), 'password' => request('password')])) {
// Authentication passed...
return response()->json(['response' => 'success', 'message' => 'You are logged in!']);
}else{
return response()->json(['response' => 'failed', 'message' => 'Sorry, you need to be logged in!']);
}
my second "else" response return is being bypass by Laravel owns json response that outputs:
{"message":"The given data was invalid.","errors":{"email":["These credentials do not match our records."]}}
How can I return anything from a failed Auth::attempt please?
I would like to d() the Auth::attempt but with json I cannot manage(any tricks on this?)
Thanks
Please or to participate in this conversation.