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

fix: revert optimization that made emailVerifyGET only update the claim if the value changes #722

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions lib/build/recipe/emailverification/api/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
39 changes: 16 additions & 23 deletions lib/build/recipe/emailverification/recipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions lib/ts/recipe/emailverification/api/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 13 additions & 17 deletions lib/ts/recipe/emailverification/recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading