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 #5260

Conversation

Mwindo
Copy link
Contributor

@Mwindo Mwindo commented Aug 16, 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 despite the failure. 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.

(Note: The bug that this PR fixes explains some of 10459. The other part is related to the old Cognito-hosted signup page. Therefore, after this fix, we should no longer be creating any users without custom:userId.)

@Mwindo Mwindo added the to test label Aug 16, 2024
@Mwindo Mwindo marked this pull request as ready for review August 16, 2024 22:00
@Mwindo Mwindo merged commit 947de02 into ustaxcourt:test Aug 20, 2024
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants