diff --git a/lib/build/recipe/webauthn/api/implementation.js b/lib/build/recipe/webauthn/api/implementation.js index 4ba799504..1bd6ba525 100644 --- a/lib/build/recipe/webauthn/api/implementation.js +++ b/lib/build/recipe/webauthn/api/implementation.js @@ -1009,27 +1009,26 @@ function getAPIImplementation() { if (generatedOptions.status !== "OK") { return generatedOptions; } - const email = generatedOptions.email; - if (email !== loginMethod.email) { - return { - status: "GENERAL_ERROR", - message: "Email mismatch", - }; - } // NOTE: Following checks will likely never throw an error as the // check for type is done in a parent function but they are kept // here to be on the safe side. - if (!email) { + if (!generatedOptions.email) { throw new Error( "Should never come here since we already check that the email value is a string in validateEmailAddress" ); } + if (generatedOptions.email !== loginMethod.email) { + return { + status: "GENERAL_ERROR", + message: "Email mismatch", + }; + } // we are using the email from the register options const registerCredentialResponse = await options.recipeImplementation.registerCredential({ webauthnGeneratedOptionsId, credential, userContext, - recipeUserId: session.getRecipeUserId().getAsString(), + recipeUserId, }); if (registerCredentialResponse.status !== "OK") { return authUtils_1.AuthUtils.getErrorStatusResponseWithReason( diff --git a/lib/ts/recipe/webauthn/api/implementation.ts b/lib/ts/recipe/webauthn/api/implementation.ts index a2f88eddb..5d2405050 100644 --- a/lib/ts/recipe/webauthn/api/implementation.ts +++ b/lib/ts/recipe/webauthn/api/implementation.ts @@ -1078,29 +1078,28 @@ export default function getAPIImplementation(): APIInterface { return generatedOptions; } - const email = generatedOptions.email; - if (email !== loginMethod.email) { - return { - status: "GENERAL_ERROR", - message: "Email mismatch", - }; - } - // NOTE: Following checks will likely never throw an error as the // check for type is done in a parent function but they are kept // here to be on the safe side. - if (!email) { + if (!generatedOptions.email) { throw new Error( "Should never come here since we already check that the email value is a string in validateEmailAddress" ); } + if (generatedOptions.email !== loginMethod.email) { + return { + status: "GENERAL_ERROR", + message: "Email mismatch", + }; + } + // we are using the email from the register options const registerCredentialResponse = await options.recipeImplementation.registerCredential({ webauthnGeneratedOptionsId, credential, userContext, - recipeUserId: session.getRecipeUserId().getAsString(), + recipeUserId, }); if (registerCredentialResponse.status !== "OK") {