Skip to content

Commit

Permalink
Fix issue of parsing email from webauthn user retrieval endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30-st committed Feb 6, 2025
1 parent a4db5f3 commit 276769f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/build/recipe/webauthn/recipeImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,16 @@ function getRecipeInterface(querier, getWebauthnConfig) {
}
const user = result.user;
// todo this might be wrong but will have to figure out - what happens when there are multiple webauthn login methods ?
const email =
const parsedEmail =
(_b = user.loginMethods.find((lm) => lm.recipeId === "webauthn")) === null || _b === void 0
? void 0
: _b.email;
if (!email) {
if (!parsedEmail) {
return {
status: "RECOVER_ACCOUNT_TOKEN_INVALID_ERROR",
};
}
email = parsedEmail;
}
if (!email) {
return {
Expand Down
5 changes: 3 additions & 2 deletions lib/ts/recipe/webauthn/recipeImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ export default function getRecipeInterface(

const user = result.user as User;
// todo this might be wrong but will have to figure out - what happens when there are multiple webauthn login methods ?
const email = user.loginMethods.find((lm) => lm.recipeId === "webauthn")?.email;
if (!email) {
const parsedEmail = user.loginMethods.find((lm) => lm.recipeId === "webauthn")?.email;
if (!parsedEmail) {
return {
status: "RECOVER_ACCOUNT_TOKEN_INVALID_ERROR",
};
}
email = parsedEmail;
}

if (!email) {
Expand Down

0 comments on commit 276769f

Please sign in to comment.