Skip to content

[SSF-145] - Cognito integration account creation#113

Open
dburkhart07 wants to merge 8 commits intomainfrom
ddb/SSF-145-cognito-integration-account-creation
Open

[SSF-145] - Cognito integration account creation#113
dburkhart07 wants to merge 8 commits intomainfrom
ddb/SSF-145-cognito-integration-account-creation

Conversation

@dburkhart07
Copy link

@dburkhart07 dburkhart07 commented Feb 21, 2026

ℹ️ Issue

Closes #145

📝 Description

This PR goes into the process of creating a new user through Cognito. Our existing Auth Service that utilized the Cognito API required a password, so we needed to use a new one that generates a temporary password, and emails it to the new user that we want to create.

When the user enters their temporary password for the first time, amplify stores a challenge that tells us that we need to create a new permanent password. Because of this, we needed to add in a new frontend modal into what we already had. From there, we can get the user cognito client sub, which is what we now store in our database.

The pantry and food manufacturer flow is slightly different, as they have linked users which are already created as they wait for approval after filling out the application. Because of that, we implement a check to see what their role is to determine if we update it in the database, or create a new user.

IMPORTANT UPDATE ABOUT AUTH: I changed the flow to now adjust the api client axios interceptor to wait to fetch the auth session before executing any api calls. This simplifies things drastically and makes it so that we do not need to do many extra checks to make sure the user is logged in already, and stops many possibilities for race conditions. As long as a frontend component is under a protected route, it should not need any useAuthenticator checks. Those that do not use this route however, will need to use useAuthenticator to get signed in information.

✔️ Verification

Run the following steps:

  • Tested users receive emails only when their email does not exist
  • Was able to successfully reset my password through the frontend UI
  • Verified pantries and food manufacturers that do not have an account receive an email, but no additional user is created (just sets the cognito client sub)

🏕️ (Optional) Future Work / Notes

Pending testing being written for this.

@Juwang110 Juwang110 self-requested a review February 23, 2026 00:51
Copy link
Member

@maxn990 maxn990 left a comment

Choose a reason for hiding this comment

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

Great first pass!

In addition to the comments I left, I found one more bug I wanted to mention. After I create an account as a pantry, the first time I try to access the dashboard after creating my account I get the following problem:

Image Image

It's fine after I refresh though

@dburkhart07 dburkhart07 requested a review from maxn990 February 24, 2026 04:04
Copy link
Member

@maxn990 maxn990 left a comment

Choose a reason for hiding this comment

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

looks really good! a few small things but otherwise looks great 🥳

Copy link

@Juwang110 Juwang110 left a comment

Choose a reason for hiding this comment

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

Everything looks good! I just slacked messaged you some clarifications on the flow (might be more for my sake) but once those are good I will approve

Copy link
Member

@maxn990 maxn990 left a comment

Choose a reason for hiding this comment

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

niceeeeee lgtm!!!

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.

4 participants