Skip to content

Commit

Permalink
fix: comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Jan 4, 2024
1 parent 758253e commit 56fa700
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/build/recipe/multifactorauth/recipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,12 @@ class Recipe extends recipeModule_1.default {
};
this.linkAccountsForFactorSetup = async (sessionUser, factorUserRecipeUserId, userContext) => {
// if we are here, it means that all the validations passed in the first place. So any error
// in this function must result in retry.
// in this function must result in retry from the validation.
// At this point, we have the recipe user for the new factor created. This means that
// when retrying for passwordless / thirdparty signInUp, where we check for existing user,
// we are going to find the user with the account info, technically converting this from
// sign up to a sign in operation. We need this behaviour to make the API repeatable.
// For emailpassword sign up, when we retry, the return point would be from the validation.
if (!sessionUser.isPrimaryUser) {
const createPrimaryRes = await recipe_3.default.getInstance().recipeInterfaceImpl.createPrimaryUser({
recipeUserId: new recipeUserId_1.default(sessionUser.id),
Expand Down
9 changes: 8 additions & 1 deletion lib/ts/recipe/multifactorauth/recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,14 @@ export default class Recipe extends RecipeModule {
userContext: UserContext
): Promise<{ status: "OK" | "RECURSE_FOR_RACE" }> => {
// if we are here, it means that all the validations passed in the first place. So any error
// in this function must result in retry.
// in this function must result in retry from the validation.

// At this point, we have the recipe user for the new factor created. This means that
// when retrying for passwordless / thirdparty signInUp, where we check for existing user,
// we are going to find the user with the account info, technically converting this from
// sign up to a sign in operation. We need this behaviour to make the API repeatable.

// For emailpassword sign up, when we retry, the return point would be from the validation.

if (!sessionUser.isPrimaryUser) {
const createPrimaryRes = await AccountLinkingRecipe.getInstance().recipeInterfaceImpl.createPrimaryUser({
Expand Down

0 comments on commit 56fa700

Please sign in to comment.