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

10353 Bug: Duplicate Cognito Accounts #5252

Merged
merged 11 commits into from
Aug 23, 2024

Conversation

Mwindo
Copy link
Contributor

@Mwindo Mwindo commented Aug 14, 2024

Cognito will throw an error with the message Alias entry already exists for a different username when we attempt to create two accounts with the same email nearly simultaneously. Unfortunately, Cognito still creates the duplicate account. We sometimes run into the error when a user quickly hits submit multiple times in CreatePetitionerAccount/CreatePetitionerAccountForm.tsx.

This PR fixes the issue on the front end by adding a debounce and deactivating the signup button. For all practical purposes, that should solve the issue.

I thought about how we might enforce no duplicate Cognito users on the back end, too, which would be ideal. I think the solution would go something like this: On getting the duplicate error message, we delete the duplicate account. This is easier said than done: because the request "fails," we don't get the duplicate Cognito user id with which to key off of. Instead, then, we would need to kick off some asynchronous task to get all users associated with the email and delete those without custom:userId or something (since our custom attributes--which we set after successfully signing up a user in Cognito--won't have been set for the failed Cognito request).

Frankly, I don't think it is worth it. I am happy enough with the front-end fix and pointing out that the issue is, after all, due to a bug with Cognito. That said, if reviewers think that this back-end solution is worthwhile, I can set it up.

@Mwindo Mwindo marked this pull request as ready for review August 21, 2024 21:30
Copy link
Collaborator

@jtdevos jtdevos left a comment

Choose a reason for hiding this comment

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

left a comment re: magic numbers - let me know if you disagree

@Mwindo
Copy link
Contributor Author

Mwindo commented Aug 22, 2024

left a comment re: magic numbers - let me know if you disagree

Sure, I can pull this out into a constant.

@Mwindo Mwindo requested a review from jtdevos August 22, 2024 18:31
@jtdevos jtdevos merged commit 3428f0c into ustaxcourt:staging Aug 23, 2024
44 checks passed
@jtdevos jtdevos mentioned this pull request Aug 23, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants