Monday, February 27, 2017

[SOLVED]Auth Issue when upgrading from Laravel 5.2 to Laravel 5.3

I have following the official guide to upgrade from laravel 5.2 to laravel 5.3: https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0
Because I needed some customizations to the default authentication I have copied the login function to Http\Controllers\Auth\AuthController.php.
Now, when I updated, the `AuthController.php' was divided into several other files.
I have copied the login function to Http\Controllers\Auth\LoginController.php
Now, I am getting the following error when trying to login:
BadMethodCallException in Controller.php line 82:
Method [getCredentials] does not exist.
The login functions below (Might not matter):
public function login(Request $request)
{
$this->validate($request, [
    'email' => 'required|email', 
    'password' => 'required',
]);

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

// This section is the only change
if (Auth::validate($credentials)) {
    $user = Auth::getLastAttempted();
    if ($user->active) {
        Auth::login($user, $request->has('remember'));

        ActivityLog::add("User has successfully logged in.", $user->id);

        return redirect()->intended($this->redirectPath());
    } else {
        return redirect($this->loginPath) // Change this to redirect elsewhere
            ->withInput($request->only('email', 'remember'))
            ->withErrors([
                'active' => 'This account has been suspended.'
            ]);
    }
}

return redirect($this->loginPath)
    ->withInput($request->only('email', 'remember'))
    ->withErrors([
        'email' => $this->getFailedLoginMessage(),
    ]);

}

How do I fix this?


from Latest question asked on Laravel tag.

via Angelin Calu

Advertisement