aws-samples/amazon-cognito-passwordless-email-auth

Can't retry login code entry

agostbiro opened this issue · 2 comments

The back end should allow 3 attempts for entering the login code, but the session is invalidated in the client after the first invalid attempt.

Steps to reproduce:

  1. Request login code
  2. Submit invalid login code
  3. Submit correct login code

Expected result:

The user should be logged in.

Actual result

The user is not logged in.

Additional context

The first Auth.sendCustomChallengeAnswer request with the INVALID code returns the following error:

Object { code: "UserLambdaValidationException", name: "UserLambdaValidationException", message: "CreateAuthChallenge failed with error 'challengeMetaData'." }

The second Auth.sendCustomChallengeAnswer request with the CORRECT code returns the following error:

Object { code: "NotAuthorizedException", name: "NotAuthorizedException", message: "Invalid session for the user." }

Apologies, the bug is not reproducible with this repo.

I traced the error back to my code and ultimately the documentation. I've implemented handlers following this repo in typed Python. I've created type definitions for the trigger events based on the docs and it seems there is an error in the docs for Create Auth Challenge Lambda Trigger:

ChallengeResult.challengeMetaData should be ChallengeResult.challengeMetadata

I've submitted an error feedback.

I have got an issue, I have raised in stack overflow also.

https://stackoverflow.com/questions/65347022/cognito-adminrespondtoauthchallenge-returns-invalid-session-for-the-user

Any help on this is appreciated.