fix(login): generate code for passkey (#10966)

# Which Problems Are Solved

When the passkey registration page (/passkey/set) is accessed externally
with only a loginName parameter, users encounter a "Missing code in
response" error. This occurs because the registration code is only
generated for invalid sessions, but external calls typically have valid
sessions.

# How the Problems Are Solved

- Moved registration code generation outside the session validity check
in `registerPasskeyLink()`
- Code is now generated for both valid and invalid sessions when not
provided
- Simplified logic: use provided code if available, otherwise generate a
new one
This commit is contained in:
Max Peintner
2025-10-27 09:17:01 +00:00
committed by GitHub
parent e7ec430dbc
commit 5d75e41d00
+8 -3
View File
@@ -107,9 +107,15 @@ export async function registerPasskeyLink(
if (!hasValidUserVerificationCheck) { if (!hasValidUserVerificationCheck) {
return { error: "User Verification Check has to be done" }; return { error: "User Verification Check has to be done" };
} }
}
if (!command.code) { // Generate registration code if not provided
// request a new code if no code is provided if (command.code && command.codeId) {
registerCode = {
id: command.codeId,
code: command.code,
};
} else {
const codeResponse = await createPasskeyRegistrationLink({ const codeResponse = await createPasskeyRegistrationLink({
serviceUrl, serviceUrl,
userId: currentUserId, userId: currentUserId,
@@ -121,7 +127,6 @@ export async function registerPasskeyLink(
registerCode = codeResponse.code; registerCode = codeResponse.code;
} }
}
} else if (command.userId && command.code && command.codeId) { } else if (command.userId && command.code && command.codeId) {
currentUserId = command.userId; currentUserId = command.userId;
registerCode = { registerCode = {