Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel: How to change default login error message: 'these credentials do not match our records'

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 ?

like image 357
S M Iftakhairul Avatar asked Mar 27 '17 18:03

S M Iftakhairul


People also ask

What does it mean by these credentials do not match our records?

This error message means that your user name and/or password that you entered to log in are not correct. Please try logging in again.

How do I change the login function in Laravel Auth?

In the user login controller in the login module, there are the following codes: $loggedIn = $this->auth->login( [ 'email' => $request->email, 'password' => $request->password, ], (bool) $request->get('remember_me', false) );

How does Laravel default authentication work?

Laravel includes built-in authentication and session services which are typically accessed via the Auth and Session facades. These features provide cookie-based authentication for requests that are initiated from web browsers. They provide methods that allow you to verify a user's credentials and authenticate the user.


2 Answers

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.',
like image 175
Alexey Mezenin Avatar answered Sep 21 '22 03:09

Alexey Mezenin


In app/Http/controllers/Auth/LoginController add below code:

protected function sendFailedLoginResponse(Request $request)
{
    throw ValidationException::withMessages([
           'username or password is incorrect!!!'
        ]);
}

In the sendFailedLoginResponse function you can redirect user to custom page or show error alert.

like image 23
Omidrayaneh Avatar answered Sep 19 '22 03:09

Omidrayaneh