Skip to content

Commit 4e988a5

Browse files
authored
Merge pull request #1032 from supertokens/fix/fix-webauthn-register-credential
fix: Use correct recipeUserId when registering a WebAuthn credential
2 parents 7fbaf44 + 1f43515 commit 4e988a5

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

lib/build/recipe/webauthn/api/implementation.js

Lines changed: 8 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ts/recipe/webauthn/api/implementation.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,29 +1078,28 @@ export default function getAPIImplementation(): APIInterface {
10781078
return generatedOptions;
10791079
}
10801080

1081-
const email = generatedOptions.email;
1082-
if (email !== loginMethod.email) {
1083-
return {
1084-
status: "GENERAL_ERROR",
1085-
message: "Email mismatch",
1086-
};
1087-
}
1088-
10891081
// NOTE: Following checks will likely never throw an error as the
10901082
// check for type is done in a parent function but they are kept
10911083
// here to be on the safe side.
1092-
if (!email) {
1084+
if (!generatedOptions.email) {
10931085
throw new Error(
10941086
"Should never come here since we already check that the email value is a string in validateEmailAddress"
10951087
);
10961088
}
10971089

1090+
if (generatedOptions.email !== loginMethod.email) {
1091+
return {
1092+
status: "GENERAL_ERROR",
1093+
message: "Email mismatch",
1094+
};
1095+
}
1096+
10981097
// we are using the email from the register options
10991098
const registerCredentialResponse = await options.recipeImplementation.registerCredential({
11001099
webauthnGeneratedOptionsId,
11011100
credential,
11021101
userContext,
1103-
recipeUserId: session.getRecipeUserId().getAsString(),
1102+
recipeUserId,
11041103
});
11051104

11061105
if (registerCredentialResponse.status !== "OK") {

0 commit comments

Comments
 (0)