diff --git a/lib/build/recipe/emailverification/api/implementation.js b/lib/build/recipe/emailverification/api/implementation.js index fe5c8ab23..5471e5f41 100644 --- a/lib/build/recipe/emailverification/api/implementation.js +++ b/lib/build/recipe/emailverification/api/implementation.js @@ -70,13 +70,7 @@ function getAPIInterface() { newSession, }; } else { - if ((await session.getClaimValue(emailVerificationClaim_1.EmailVerificationClaim)) !== false) { - await session.setClaimValue( - emailVerificationClaim_1.EmailVerificationClaim, - false, - userContext - ); - } + await session.setClaimValue(emailVerificationClaim_1.EmailVerificationClaim, false, userContext); return { status: "OK", isVerified: false, diff --git a/lib/build/recipe/emailverification/recipe.js b/lib/build/recipe/emailverification/recipe.js index 96faa4eb0..6f8031a23 100644 --- a/lib/build/recipe/emailverification/recipe.js +++ b/lib/build/recipe/emailverification/recipe.js @@ -187,30 +187,23 @@ class Recipe extends recipeModule_1.default { // We also have the sub cases here that the account that just // got verified was already linked to the session's primary user ID, // but either way, we don't need to change any user ID. - // In this case, all we do is to update the emailverification claim if it's - // not already set to true (it is ok to assume true cause this function - // is only called when the email is verified). - if ( - (await input.session.getClaimValue(emailVerificationClaim_1.EmailVerificationClaim)) !== - true - ) { - try { - // EmailVerificationClaim will be based on the recipeUserId - // and not the primary user ID. - await input.session.fetchAndSetClaim( - emailVerificationClaim_1.EmailVerificationClaim, - input.userContext - ); - } catch (err) { - // This should never happen, since we've just set the status above. - if (err.message === "UNKNOWN_USER_ID") { - throw new error_2.default({ - type: error_2.default.UNAUTHORISED, - message: "Unknown User ID provided", - }); - } - throw err; + // In this case, all we do is to update the emailverification claim + try { + // EmailVerificationClaim will be based on the recipeUserId + // and not the primary user ID. + await input.session.fetchAndSetClaim( + emailVerificationClaim_1.EmailVerificationClaim, + input.userContext + ); + } catch (err) { + // This should never happen, since we've just set the status above. + if (err.message === "UNKNOWN_USER_ID") { + throw new error_2.default({ + type: error_2.default.UNAUTHORISED, + message: "Unknown User ID provided", + }); } + throw err; } return; } else { diff --git a/lib/ts/recipe/emailverification/api/implementation.ts b/lib/ts/recipe/emailverification/api/implementation.ts index 74d333455..b5b244d88 100644 --- a/lib/ts/recipe/emailverification/api/implementation.ts +++ b/lib/ts/recipe/emailverification/api/implementation.ts @@ -93,9 +93,7 @@ export default function getAPIInterface(): APIInterface { newSession, }; } else { - if ((await session.getClaimValue(EmailVerificationClaim)) !== false) { - await session.setClaimValue(EmailVerificationClaim, false, userContext); - } + await session.setClaimValue(EmailVerificationClaim, false, userContext); return { status: "OK", diff --git a/lib/ts/recipe/emailverification/recipe.ts b/lib/ts/recipe/emailverification/recipe.ts index 1ebd6e5bf..18abe8182 100644 --- a/lib/ts/recipe/emailverification/recipe.ts +++ b/lib/ts/recipe/emailverification/recipe.ts @@ -304,24 +304,20 @@ export default class Recipe extends RecipeModule { // got verified was already linked to the session's primary user ID, // but either way, we don't need to change any user ID. - // In this case, all we do is to update the emailverification claim if it's - // not already set to true (it is ok to assume true cause this function - // is only called when the email is verified). - if ((await input.session.getClaimValue(EmailVerificationClaim)) !== true) { - try { - // EmailVerificationClaim will be based on the recipeUserId - // and not the primary user ID. - await input.session.fetchAndSetClaim(EmailVerificationClaim, input.userContext); - } catch (err) { - // This should never happen, since we've just set the status above. - if ((err as Error).message === "UNKNOWN_USER_ID") { - throw new SessionError({ - type: SessionError.UNAUTHORISED, - message: "Unknown User ID provided", - }); - } - throw err; + // In this case, all we do is to update the emailverification claim + try { + // EmailVerificationClaim will be based on the recipeUserId + // and not the primary user ID. + await input.session.fetchAndSetClaim(EmailVerificationClaim, input.userContext); + } catch (err) { + // This should never happen, since we've just set the status above. + if ((err as Error).message === "UNKNOWN_USER_ID") { + throw new SessionError({ + type: SessionError.UNAUTHORISED, + message: "Unknown User ID provided", + }); } + throw err; } return;