mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-21 20:38:47 +00:00
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:
@@ -107,20 +107,25 @@ 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) {
|
||||||
const codeResponse = await createPasskeyRegistrationLink({
|
registerCode = {
|
||||||
serviceUrl,
|
id: command.codeId,
|
||||||
userId: currentUserId,
|
code: command.code,
|
||||||
});
|
};
|
||||||
|
} else {
|
||||||
|
const codeResponse = await createPasskeyRegistrationLink({
|
||||||
|
serviceUrl,
|
||||||
|
userId: currentUserId,
|
||||||
|
});
|
||||||
|
|
||||||
if (!codeResponse?.code?.code) {
|
if (!codeResponse?.code?.code) {
|
||||||
return { error: "Could not create registration link" };
|
return { error: "Could not create registration link" };
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user