0

I'm made a cognito passwordless flow and i create userPool with this SAM template:

UserPool:
    Type: "AWS::Cognito::UserPool"
    Properties:
      UserPoolName: !Ref UserPoolName
      Schema:
        - Name: phone_number
          AttributeDataType: String
          Mutable: true
        - Name: email
          AttributeDataType: String
          Mutable: true
      Policies:
        PasswordPolicy:
          MinimumLength: 6
          RequireLowercase: false
          RequireNumbers: false
          RequireSymbols: false
          RequireUppercase: false
      AliasAttributes:
        - email
        - phone_number
      MfaConfiguration: "OFF"

UserPoolClient:
    Type: "AWS::Cognito::UserPoolClient"
    Properties:
      ClientName: sms-auth-client
      GenerateSecret: false
      UserPoolId: !Ref UserPool
      ExplicitAuthFlows:
        - CUSTOM_AUTH_FLOW_ONLY

Here, the User can use a email or phone_number to sign in, both of them are aliases.

But, Is there a way to identify which alias the User uses on sign in inside create-auth-lambda trigger?

Anyone can help?

Rafael de Carvalho
  • 501
  • 1
  • 5
  • 10
  • perhaps check the string format? – jspcal Feb 01 '23 at 20:45
  • either logging in with the phone number or email, I get the same parameters in the lambda trigger event. I can't check the username string because I always get the same event with all user attributes. – Rafael de Carvalho Feb 02 '23 at 12:33

1 Answers1

0

Thats the answer: https://dev.to/duarten/passwordless-authentication-with-cognito-13c

Its a bit confused flow but it works fine.

Rafael de Carvalho
  • 501
  • 1
  • 5
  • 10