ellaisys / aws-cognito

AWS Cognito package (with MFA Feature) using the AWS SDK for PHP/Laravel
https://ellaisys.github.io/aws-cognito/
MIT License
110 stars 41 forks source link

Call of "$claim = $this->attemptLogin..." returns false on user first login #82

Closed cdo9 closed 4 months ago

cdo9 commented 11 months ago

Describe the bug I'am using this as API.

Like i said in the title, when i register a new user, the first login i made in my app to the attemptLogin function returns false instead of the array with tokens. Only the first try after new registration.

To fix the issue i've done this :

$claim = $this->attemptLogin($collection, 'api', 'email', 'password', true);
if($claim === false) $claim = $this->attemptLogin($collection, 'api', 'email', 'password', true);

The false is returned by Auth::guard($guard)->attempt($credentials, $rememberMe); in Ellaisys\Cognito\Auth\AutheticasUsers.php

Thanks you,

Christophe

mlab817 commented 9 months ago

After going through this problem, I found that this configuration addresses this issue:

https://github.com/ellaisys/aws-cognito#automatic-user-password-update-for-api-usage-for-new-cognito-users

It seems that first login will return false because the new user needs to change their password. Leaving this here to help others who may encounter the same issue in the future.

amarnik commented 6 months ago

run into the same problem where first time login always resulted in the error created a small PR that is fixing the problem: https://github.com/ellaisys/aws-cognito/pull/92

amitdhongde commented 4 months ago

@amarnik Thank you for the PR. I have merged that change.