Skip to content

Commit

Permalink
feat: detect email_change_not_allowed earlier to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Sep 30, 2024
1 parent bc7403d commit 47df0a2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/build/recipe/thirdparty/api/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ function getAPIInterface() {
shouldTryLinkingWithSessionUser: input.shouldTryLinkingWithSessionUser,
});
if (preAuthChecks.status !== "OK") {
if (
preAuthChecks.status === "SIGN_IN_NOT_ALLOWED" &&
authenticatingUser !== undefined &&
!authenticatingUser.loginMethod.hasSameEmailAs(emailInfo.id)
) {
return {
status: "SIGN_IN_UP_NOT_ALLOWED",
reason:
"Cannot sign in / up because new email cannot be applied to existing account. Please contact support. (ERR_CODE_005)",
};
}
logger_1.logDebugMessage(
"signInUpPOST: erroring out because preAuthChecks returned " + preAuthChecks.status
);
Expand Down
11 changes: 11 additions & 0 deletions lib/ts/recipe/thirdparty/api/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ export default function getAPIInterface(): APIInterface {
});

if (preAuthChecks.status !== "OK") {
if (
preAuthChecks.status === "SIGN_IN_NOT_ALLOWED" &&
authenticatingUser !== undefined &&
!authenticatingUser.loginMethod.hasSameEmailAs(emailInfo.id)
) {
return {
status: "SIGN_IN_UP_NOT_ALLOWED",
reason:
"Cannot sign in / up because new email cannot be applied to existing account. Please contact support. (ERR_CODE_005)",
};
}
logDebugMessage("signInUpPOST: erroring out because preAuthChecks returned " + preAuthChecks.status);
// On the frontend, this should show a UI of asking the user
// to login using a different method.
Expand Down

0 comments on commit 47df0a2

Please sign in to comment.