Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 39 additions & 8 deletions samples/apps/react-vanilla-sample/src/pages/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@ const LoginPage = () => {
setRegOnlySuccess(true);
}
} else if (data.type === "VIEW") {
// Check for passkey creation options in additionalData - check this first
if (data.data?.additionalData?.passkeyCreationOptions) {
setPasskeyCreationOptions(data.data.additionalData.passkeyCreationOptions);
}
// Check for passkey authentication challenge in additionalData - check this first
if (data.data?.additionalData?.passkeyChallenge) {
setPasskeyChallenge(data.data.additionalData.passkeyChallenge);
}

// Handle the VIEW response
// Check if this is an input prompt (has inputs to collect)
if (data.data?.inputs && data.data.inputs.length > 0) {
Expand All @@ -325,14 +334,6 @@ const LoginPage = () => {
if (data.data?.actions) {
setAvailableActions(data.data.actions);
}
// Check for passkey creation options in additionalData
if (data.data?.additionalData?.passkeyCreationOptions) {
setPasskeyCreationOptions(data.data.additionalData.passkeyCreationOptions);
}
// Check for passkey authentication challenge in additionalData
if (data.data?.additionalData?.passkeyChallenge) {
setPasskeyChallenge(data.data.additionalData.passkeyChallenge);
}
} else if (data.data?.actions && data.data.actions.length > 1) {
// This is a decision screen - multiple actions to choose from
setNeedsDecision(true);
Expand Down Expand Up @@ -404,6 +405,8 @@ const LoginPage = () => {
setRedirectURL(null);
setSocialIdpName('');
setRegOnlySuccess(false);
setPasskeyCreationOptions(null);
setPasskeyChallenge(null);

initiateNativeAuthFlow(isSignupMode ? 'REGISTRATION' : 'LOGIN')
.then((result) => {
Expand All @@ -419,6 +422,15 @@ const LoginPage = () => {
setError(true);
setErrorMessage(data.failureReason || defaultMessage);
} else if (data.type === "VIEW") {
// Check for passkey creation options in additionalData - check this first
if (data.data?.additionalData?.passkeyCreationOptions) {
setPasskeyCreationOptions(data.data.additionalData.passkeyCreationOptions);
}
// Check for passkey authentication challenge in additionalData - check this first
if (data.data?.additionalData?.passkeyChallenge) {
setPasskeyChallenge(data.data.additionalData.passkeyChallenge);
}

// Handle the VIEW response
// Check if this is an input prompt (has inputs to collect)
if (data.data?.inputs && data.data.inputs.length > 0) {
Expand Down Expand Up @@ -483,6 +495,8 @@ const LoginPage = () => {
setSocialIdpName('');
setRegOnlySuccess(false);
setPromptRegistration(false);
setPasskeyCreationOptions(null);
setPasskeyChallenge(null);

// Ensure all input fields are present in formData, even if empty
const completeFormData = { ...formData };
Expand All @@ -504,6 +518,15 @@ const LoginPage = () => {
setError(true);
setErrorMessage(data.failureReason || 'Registration failed. Please check your information.');
} else if (data.type === "VIEW") {
// Check for passkey creation options in additionalData - check this first
if (data.data?.additionalData?.passkeyCreationOptions) {
setPasskeyCreationOptions(data.data.additionalData.passkeyCreationOptions);
}
// Check for passkey authentication challenge in additionalData - check this first
if (data.data?.additionalData?.passkeyChallenge) {
setPasskeyChallenge(data.data.additionalData.passkeyChallenge);
}

// Handle the VIEW response
// Check if this is an input prompt (has inputs to collect)
if (data.data?.inputs && data.data.inputs.length > 0) {
Expand Down Expand Up @@ -634,6 +657,9 @@ const LoginPage = () => {
})
.catch((error) => {
console.error("Error submitting passkey credential:", error);
setConnectionError(false);
setNeedsDecision(false);
setAvailableActions([]);
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for passkey credential submission (lines 660-662) clears fewer state variables compared to the passkey assertion error handler (lines 696-700). For consistency and to ensure a clean UI state on errors, consider also clearing setSelectedAction(null), setFormData({}), and setInputs([]) in this error handler, similar to the passkey assertion error handler.

Suggested change
setAvailableActions([]);
setAvailableActions([]);
setSelectedAction(null);
setFormData({});
setInputs([]);

Copilot uses AI. Check for mistakes.
handleSubmissionError(error);
});
};
Expand Down Expand Up @@ -667,6 +693,11 @@ const LoginPage = () => {
})
.catch((error) => {
console.error("Error submitting passkey assertion:", error);
setNeedsDecision(false);
setAvailableActions([]);
setSelectedAction(null);
setFormData({});
setInputs([]);
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The passkey credential error handler resets connectionError to false before calling handleSubmissionError, but the passkey assertion error handler (line 696-700) does not. For consistency, consider adding setConnectionError(false) before calling handleSubmissionError in the passkey assertion error handler as well, to ensure any previous connection error state is cleared.

Suggested change
setInputs([]);
setInputs([]);
setConnectionError(false);

Copilot uses AI. Check for mistakes.
handleSubmissionError(error);
});
};
Expand Down
Loading