lundi 27 février 2017

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: http://ift.tt/29vUJ0Q

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 Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2mC9nFH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire