Skip to content

Conversation

@ErikCH
Copy link
Contributor

@ErikCH ErikCH commented Jul 12, 2022

Description of changes

When a user signs up and has MFA TOTP enabled, the user object is not set correctly. To correct this, instead of returing the values from Auth.verifyTOTP I send back the values from Auth.currentAuthenticatedUser

Issue #, if available

closes #2274

Description of how you validated changes

Created additional e2e test

Checklist

  • PR description included
  • yarn test passes
  • Tests are updated
  • No side effects or sideEffects field updated
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ErikCH ErikCH requested a review from a team as a code owner July 12, 2022 23:54
@changeset-bot
Copy link

changeset-bot bot commented Jul 12, 2022

🦋 Changeset detected

Latest commit: 0157f16

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@aws-amplify/ui Patch
@aws-amplify/ui-react Patch
@aws-amplify/ui-vue Patch
@aws-amplify/ui-angular Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines 60 to 79
@angular @react @vue
Scenario: Successful sign up shows correct email from authenticated user
When I click the "Create Account" tab
And I type a new "email"
And I type my password
And I confirm my password
And I click the "Create Account" button
Then I see "Confirmation Code"
And I type a valid confirmation code
And I intercept '{ "headers": { "X-Amz-Target": "AWSCognitoIdentityProviderService.ConfirmSignUp" } }' with fixture "confirm-sign-up-with-email"
# Mocking these two calls is much easier than intercepting 6+ network calls with tokens that are validated & expire within the hour
And I mock 'Amplify.Auth.signIn' with fixture "Auth.signIn-mfa-setup"
And I mock 'Amplify.Auth.currentAuthenticatedUser' with fixture "Auth.currentAuthenticatedUser-setup-TOTP"
And I click the "Confirm" button
Then I see "Setup TOTP"
Then I see "Code"
And I type a valid confirmation code
And I mock 'Amplify.Auth.verifyTotpToken' with fixture "Auth.verifyTOTP"
And I click the "Confirm" button
Then I see "test@example.com"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This mocks the setup totp flow, and verifies the email address being sent back is from he Auth.currentAuthenticatedUser not the values from Auth.verifyTotopToken.

@@ -0,0 +1,3 @@
{
"email": "test@example.com"
Copy link
Contributor Author

@ErikCH ErikCH Jul 13, 2022

Choose a reason for hiding this comment

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

In the real Auth.currentAuthenticatedUser method there are many different values being returned. For simplicity sake, all I care is that this is being called and it returns this value for email.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

*changed this to username instead.

@ErikCH ErikCH temporarily deployed to ci July 13, 2022 15:26 Inactive
@ErikCH ErikCH temporarily deployed to ci July 13, 2022 15:26 Inactive
@ErikCH ErikCH temporarily deployed to ci July 13, 2022 15:26 Inactive
@ErikCH ErikCH temporarily deployed to ci July 13, 2022 15:26 Inactive
Copy link
Member

@calebpollman calebpollman left a comment

Choose a reason for hiding this comment

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

Left some questions/feedback, but it seems like this might be a bug on the Amplify JS side from reading the initial ticket?

@lgtm-com
Copy link

lgtm-com bot commented Jul 13, 2022

This pull request introduces 1 alert when merging 491a2eb into 660d9b6 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@ErikCH ErikCH temporarily deployed to ci July 13, 2022 21:21 Inactive
@ErikCH ErikCH temporarily deployed to ci July 13, 2022 21:21 Inactive
@ErikCH ErikCH temporarily deployed to ci July 13, 2022 21:21 Inactive
@ErikCH ErikCH temporarily deployed to ci July 13, 2022 21:21 Inactive
@ErikCH ErikCH requested a review from calebpollman July 13, 2022 21:45
@lgtm-com
Copy link

lgtm-com bot commented Jul 13, 2022

This pull request introduces 1 alert when merging 2461f5c into 660d9b6 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@ErikCH ErikCH temporarily deployed to ci July 13, 2022 21:51 Inactive
@ErikCH ErikCH temporarily deployed to ci July 13, 2022 21:51 Inactive
@ErikCH ErikCH temporarily deployed to ci July 13, 2022 21:51 Inactive
@ErikCH ErikCH temporarily deployed to ci July 13, 2022 21:51 Inactive
@ErikCH ErikCH temporarily deployed to ci July 21, 2022 23:12 Inactive
@ErikCH ErikCH temporarily deployed to ci July 21, 2022 23:13 Inactive
@ErikCH ErikCH temporarily deployed to ci July 21, 2022 23:13 Inactive
@ErikCH ErikCH temporarily deployed to ci July 21, 2022 23:13 Inactive
Comment on lines +60 to +61
@angular @react @vue
Scenario: Successful sign up shows correct username from authenticated user
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

@calebpollman calebpollman left a comment

Choose a reason for hiding this comment

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

LGTM 🚢

@ErikCH ErikCH merged commit 8418028 into main Jul 22, 2022
@ErikCH ErikCH deleted the fix-wrong-user-mfa-sign-up branch July 22, 2022 16:08
@github-actions github-actions bot mentioned this pull request Jul 22, 2022
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.

useAuthenticator returns wrong user object in first MFA login with TOTP

3 participants