Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(amplify_authenticator): authenticator phone OR email confirmation #1785

Conversation

Jordan-Nelson
Copy link
Member

Issue #, if available:

Description of changes:

  • Update state management of username selection
  • Add integration test for Email OR Phone configs

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@@ -178,9 +178,9 @@ Future<void> adminCreateUser(
}
}

/// Returns the OTP code for [username]. Must be called before the network call
/// Returns the OTP code for [email]. Must be called before the network call
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The lambdas (for "email" auth and "email OR phone" auth) are set up to use the email address, regardless of what is being used for a "username".

This didn't have to change, but the new tests I added where phone number is the username were a bit confusing to read without the change.

@Jordan-Nelson Jordan-Nelson enabled auto-merge (squash) June 21, 2022 19:57
dnys1
dnys1 previously approved these changes Jun 21, 2022
Copy link
Contributor

@dnys1 dnys1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

// Reset current username value to align with the current switch state.
String newUsername = useEmail
String newUsername = newUsernameSelection ==
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String newUsername = newUsernameSelection ==
final newUsername = newUsernameSelection ==

Comment on lines 68 to 70
SignUpPage signUpPage = SignUpPage(tester: tester);
ConfirmSignUpPage confirmSignUpPage = ConfirmSignUpPage(tester: tester);
SignInPage signInPage = SignInPage(tester: tester);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SignUpPage signUpPage = SignUpPage(tester: tester);
ConfirmSignUpPage confirmSignUpPage = ConfirmSignUpPage(tester: tester);
SignInPage signInPage = SignInPage(tester: tester);
final signUpPage = SignUpPage(tester: tester);
final confirmSignUpPage = ConfirmSignUpPage(tester: tester);
final signInPage = SignInPage(tester: tester);

Comment on lines 118 to 120
SignUpPage signUpPage = SignUpPage(tester: tester);
ConfirmSignUpPage confirmSignUpPage = ConfirmSignUpPage(tester: tester);
SignInPage signInPage = SignInPage(tester: tester);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SignUpPage signUpPage = SignUpPage(tester: tester);
ConfirmSignUpPage confirmSignUpPage = ConfirmSignUpPage(tester: tester);
SignInPage signInPage = SignInPage(tester: tester);
final signUpPage = SignUpPage(tester: tester);
final confirmSignUpPage = ConfirmSignUpPage(tester: tester);
final signInPage = SignInPage(tester: tester);

// Then I see "Sign out"
await signInPage.expectAuthenticated();
},
skip: !isMobile,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can skip on the group

// Reset current username value to align with the current switch state.
String newUsername = useEmail
String newUsername = newUsernameSelection ==
UsernameSelection.email
? state.getAttribute(CognitoUserAttributeKey.email) ?? ''
: state.getAttribute(
CognitoUserAttributeKey.phoneNumber) ??
'';
state.username = newUsername;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since .username and .usernameSelection both trigger rebuilds, I think setting the username first might make more sense?

haverchuck
haverchuck previously approved these changes Jun 21, 2022
@Jordan-Nelson Jordan-Nelson dismissed stale reviews from haverchuck and dnys1 via 72261b1 June 22, 2022 14:41
@Jordan-Nelson Jordan-Nelson merged commit 666349a into aws-amplify:main Jun 22, 2022
@Jordan-Nelson Jordan-Nelson deleted the fix/main/authenticator-phone-number-confirmation branch June 22, 2022 20:01
Jordan-Nelson added a commit to Jordan-Nelson/amplify-flutter that referenced this pull request Jun 22, 2022
…aws-amplify#1785)

* fix(authenticator): move username selection state to authenticator state

* chore; update imports

* test: add integration tests for email or phone configs

* chore: move username input enum
Jordan-Nelson added a commit that referenced this pull request Jun 27, 2022
…#1785) (#1805)

* fix(authenticator): move username selection state to authenticator state

* chore; update imports

* test: add integration tests for email or phone configs

* chore: move username input enum
Jordan-Nelson added a commit to Jordan-Nelson/amplify-flutter that referenced this pull request Jun 28, 2022
…aws-amplify#1785)

* fix(authenticator): move username selection state to authenticator state

* chore; update imports

* test: add integration tests for email or phone configs

* chore: move username input enum
Jordan-Nelson added a commit that referenced this pull request Jun 29, 2022
…#1785)

* fix(authenticator): move username selection state to authenticator state

* chore; update imports

* test: add integration tests for email or phone configs

* chore: move username input enum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants