ArranJacques / laravel-aws-cognito-auth

An authentication driver for Laravel for authenticating users in AWS Cognito User Pools.
Other
74 stars 26 forks source link

Can't login #10

Closed muresanandrei closed 6 years ago

muresanandrei commented 6 years ago

When i try to login I get the following error:

Type error: Argument 1 passed to Pallant\LaravelAwsCognitoAuth\AwsCognitoIdentityGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, null given, called in /Users/andrei/Projects/Projects_2/project/vendor/pallant/laravel-aws-cognito-auth/src/AwsCognitoIdentityGuard.php on line 446

This is the login code:

$attempt = Auth::attempt([ 'email' => $request['email'], 'password' => $request['password'], ], false, AWS_COGNITO_AUTH_RETURN_ATTEMPT);

    if ($attempt->successful()) {
        return redirect('/dashboard');
    } else {
        $response = $attempt->getResponse();
        dd($response);
    }
zoul0813 commented 6 years ago

Do you have a User in the DB that matches the email/password you’re trying to Auth?

muresanandrei commented 6 years ago

You mean not on aws db?

zoul0813 commented 6 years ago

Correct - Cognito is not treated as a "database of users", and is only used to authorize the users. A request to cognito is not made unless the user exists in the apps DB.

muresanandrei commented 6 years ago

So I also have to save the user on users table on my own db thanks.

Dayjo commented 6 years ago

Thanks @zoul0813, this is clearly not obvious from the documentation, we'll try and make this clearer.

@muresanandrei This way allows you to still maintain a database of users yourself for any extra details or links to other models etc.

ArranJacques commented 6 years ago

I've added some additional documentation to the readme to help clarify this point.

https://github.com/pallant/laravel-aws-cognito-auth/tree/v1.1.2#users-table