Sunday, March 19, 2017

Laravel Auth attempt() not working despite correct credentials

I am currently writing an Authentication controller for my Laravel API application, and I have decided to authenticate my system with JWT-Auth.

I am attempting to login using valid credentials, yet the JWTAuth::attempt() method returns false.

Here's my controller

public function login(Request $request)
{
    $credentials = $request->only('email', 'password');
    $user = User::where('email', $credentials['email'])->where('active', 1)->first();
    if ($user && $token = $this->auth->attempt($credentials)) {
        $remember = true;
        event(new Login($this->auth->user(), $remember));
        return $token;
    }
}

I feel like the error lies somewhere in my configuration.

Any ideas what might be triggering this issue.



via AdamMcquiff

Advertisement