Overriding Custom Login Error Messages In Laravel 5.2

- 1 answer

I've been struggling with laravel 5.2 login function messages. I've override the default sendFailedLoginResponse function in AuthController which works for failed attempts.

But I need to override the validate function response as well which I could not figure out how to do that. Also I do not want to override the default login functionality in the AuthContrller and want to stick with the same login function.

The reason for overriding the validate function is that am making an angular app and want the response in json format with some custom keys.

Currently default login function in Illuminate\Foundation\Auth\AuthenticateUsers.php

public function login(Request $request)
    $this->validate($request, [
        $this->loginUsername() => 'required', 'password' => 'required',
    // If the class is using the ThrottlesLogins trait, we can automatically throttle
    // the login attempts for this application. We'll key this by the username and
    // the IP address of the client making these requests into this application.
    $throttles = $this->isUsingThrottlesLoginsTrait();

    if ($throttles && $this->hasTooManyLoginAttempts($request)) {
        return $this->sendLockoutResponse($request);

    $credentials = $this->getCredentials($request);

    if (Auth::guard($this->getGuard())->attempt($credentials, $request->has('remember'))) {
        return $this->handleUserWasAuthenticated($request, $throttles);

    // If the login attempt was unsuccessful we will increment the number of attempts
    // to login and redirect the user back to the login form. Of course, when this
    // user surpasses their maximum number of attempts they will get locked out.
    if ($throttles) {

    return $this->sendFailedLoginResponse($request);

I want the response something like in the below sendFailedResponse function in AuthController

 * Get failed request response
 * @param null
 * @return null
public function sendFailedLoginResponse()
    return response()->json( [ 'status' => false, 'message' => $this->getFailedLoginMessage() ]);




I came up with the solution by implementing JWT for authentication which I could think of is the best solution with Client side.