Page updated Jan 16, 2024

CLI Auth Signup Changes

Who is affected?

This article is relevant to you if you have an Auth resource created using amplify add auth with CLI versions 5.2.0 - 5.6.0.

If your Auth resource was created with amplify add auth using Amplify CLI Version 5.1.2 or earlier, or with Amplify CLI version 6.0.0 or later, you are not affected and you can ignore the rest of this article.

What Changed

The Original CLI amplify add auth Behavior (versions prior to 5.2.0)

Prior to CLI version 5.2.0, developers could choose one of these options:

How do you want users to be able to sign in? (Use the arrow keys) >Email Username Phone Number Email or Phone Number
1How do you want users to be able to sign in? (Use the arrow keys)
2>Email
3 Username
4 Phone Number
5 Email or Phone Number

The Changed CLI amplify add auth Behavior (CLI versions 5.2.0 - 5.6.0)

In the CLI release 5.2.0 (July 27, 2021), additional functionality was added for developers configuring Auth. Beginning in CLI version 5.2.0, developers could choose any of these options

How do you want users to be able to sign in? [x] Email Address [ ] Phone Number [ ] Username
1How do you want users to be able to sign in?
2[x] Email Address
3[ ] Phone Number
4[ ] Username

Back to the Original Behavior (CLI version 6.0.0 and later)

Beginning in CLI v6.0.0, the original behavior is reinstated and developers can once again choose one of these options:

How do you want users to be able to sign in? (Use the arrow keys) >Email Username Phone Number Email or Phone Number
1How do you want users to be able to sign in? (Use the arrow keys)
2>Email
3 Username
4 Phone Number
5 Email or Phone Number

What is the impact of this change

If you configured the Auth Resource with the changed amplify add auth behavior (CLI v5.2 - v5.6) you will need to use the changed amplify add auth behavior whenever you run amplify add auth in order to get a compatible configuration. You can use the changed amplify add auth behavior in CLI v6.0.0 by enabling the "auth.forceAliasAttributes" feature flag.

The following code segment demonstrates how Auth.signup() can be used with the Auth resource created with CLI versions 5.2.0 - 5.6.0:

const username = getGUID(); const { user } = await Auth.signUp({ username, password: 'your-secure-password', attributes: { email: 'youremail@yourdomain.com' } }); await Auth.confirmSignUp(username, code); await Auth.signIn('youremail@yourdomain.com', 'your-secure-password');
1const username = getGUID();
2const { user } = await Auth.signUp({
3 username,
4 password: 'your-secure-password',
5 attributes: {
6 email: 'youremail@yourdomain.com'
7 }
8});
9await Auth.confirmSignUp(username, code);
10await Auth.signIn('youremail@yourdomain.com', 'your-secure-password');

The following code segment demonstrates how Auth.signup() can be used with the Auth resource created with CLI versions 6.0 and later (this segment would not work for Auth configured with CLI 5.2.0 - 5.6.0):

const { user } = await Auth.signUp({ username: 'youremail@yourdomain.com', password: 'your-secure-password', attributes: { email: 'youremail@yourdomain.com' } });
1const { user } = await Auth.signUp({
2 username: 'youremail@yourdomain.com',
3 password: 'your-secure-password',
4 attributes: {
5 email: 'youremail@yourdomain.com'
6 }
7});