Can I signup with email or phone number with a password without Username and alias them later

Question:

Hi I would like to have my app can be signup either using Email Address or Phone Number using AWS Cognito Pool checking on Allow both email addresses and phone numbers (users can choose one).

But I want to ask users for Email address later (If they signed up with Phone number or ask for phone number if they signed up with Email address)

And I found that the options Email address or phone number in Cognito Userpool can not do the alias between Phone number and Email address but uses them as a Username instead.

In the same time, the Username option requires us to have a unique Username to signup but Username is no point in my application and I don’t want user to type in many boxes while signing up.

Is there anyway I can achieve what I want using AWS Cognito UserPool ?

Answer:

When you set up your Cognito user pool to begin with, if you select the option to “let users use email as username” and also make sure you require phone verification.

https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-email-phone-verification.html

Then when your users sign up, if you handle your front end auth/signup/confim flow yourself as seen here:
https://docs.aws.amazon.com/cognito/latest/developerguide/using-amazon-cognito-user-identity-pools-javascript-examples.html

You can confirm whatever method you want.
I highly recommend you read the link above and handle the confirm flow yourself.

Also, when you get your user attributes object on the front end you can see what is verified:

Leave a Reply