Skip to content

@W-21253277 Passkey login cancelled after user logs in or navigates away#3688

Merged
hajinsuha1 merged 34 commits intofeature/webauthn-loginfrom
W-21253277-passkey-login-cancelled-after-user-logs-in
Feb 26, 2026
Merged

@W-21253277 Passkey login cancelled after user logs in or navigates away#3688
hajinsuha1 merged 34 commits intofeature/webauthn-loginfrom
W-21253277-passkey-login-cancelled-after-user-logs-in

Conversation

@hajinsuha1
Copy link
Collaborator

@hajinsuha1 hajinsuha1 commented Feb 23, 2026

Description

Updates pages/login/index.jsx and use-auth-modal.jsx and contact-info to abort the passkey login if a user

  • navigates away from the page
  • logs in with a different method

Before this change, for passkey prompts that allow the page to still be interactive (e.g., 1Password) if the user logs in with a different method or navigates away from the page the passkey prompt wouldn't be dismissed.

Screenshare.-.2026-02-23.4_45_57.PM.mp4

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • Refactored passkey login logic in ContactInfo component to only prompt when step is not CONTACT_INFO
  • Updated AuthModal, Login, ContactInfo to abort passkey login when unmounted
  • Added abort functionality to usePasskeyLogin hook
  • Enhanced passkey login handling with abort in

How to Test-Drive This PR

Base URL: https://wasatch-mrt-passwordless-poc.mrt-storefront-staging.com/us/en-US/
Environment without fix Base URL: https://wasatch-mrt-feature-private.mrt-storefront-staging.com/us/en-US/

Require a passkey authenticator that allows page interactions during passkey prompt e.g., 1Password

Notes

  • Re-prompt scenarios apply to passkey managers (e.g., 1Password) that allow page interaction while prompt is open
  • Keep browser console open to verify no errors are logged

Login Page

Logged-in user sees no passkey prompt

  1. Log in using any method
  2. Navigate to https://wasatch-mrt-passwordless-poc.mrt-storefront-staging.com/us/en-US/login
  3. Verify no passkey prompt appears
loginPage_registered_noPrompt.mp4

Navigate away + dismiss prompt: no re-prompt

  1. Navigate to https://wasatch-mrt-passwordless-poc.mrt-storefront-staging.com/us/en-US/login
  2. Wait for passkey prompt, navigate away from login page
  3. Dismiss passkey prompt (click X)
  4. Verify no additional prompts appear
loginPage_unmount_aborts.mp4

Password login + dismiss prompt: no re-prompt

  1. Navigate to https://wasatch-mrt-passwordless-poc.mrt-storefront-staging.com/us/en-US/login
  2. Wait for passkey prompt, log in with email/password
  3. Dismiss passkey prompt (click X)
  4. Verify no additional prompts appear
loginPage_login_aborts.mp4

Auth Modal

Close modal + dismiss prompt: no re-prompt

  1. Click the profile icon in the top right to open auth modal
  2. Wait for passkey prompt, close the auth modal
  3. Dismiss passkey prompt (click X)
  4. Verify no additional prompts appear
Screenshare.-.2026-02-24.9_35_16.AM.mp4

Password login + dismiss prompt: no re-prompt

  1. Click the profile icon in the top right to open auth modal
  2. Wait for passkey prompt, log in with email/password
  3. Dismiss passkey prompt (click X)
  4. Verify no additional prompts appear
authModal_login_aborts.mp4

Contact Info (Checkout)

Navigate away + dismiss prompt: no re-prompt

  1. Add product to cart, and proceed to Checkout
  2. Wait for passkey prompt, navigate away from checkout
  3. Dismiss passkey prompt (click X)
  4. Verify no additional prompts appear
contactInfo_unmount_aborts.mp4

Checkout as guest + dismiss prompt: no re-prompt

  1. Add product to cart, and proceed to Checkout
  2. Enter email, wait for passkey prompt, click "Checkout as Guest"
  3. Dismiss passkey prompt (click X)
  4. Verify no additional prompts appear
contactInfo_checkoutAsGuest_abort.mp4

Password login + dismiss prompt: no re-prompt

  1. Add product to cart, and proceed to Checkout
  2. Enter email, wait for passkey prompt, log in with email/password
  3. Dismiss passkey prompt (click X)
  4. Verify no additional prompts appear
contactInfo_login_aborts.mp4

Logged-in user sees no passkey prompt

  1. Navigate back to the checkout page as a logged in user https://wasatch-mrt-passwordless-poc.mrt-storefront-staging.com/us/en-US/checkout
  2. Verify no passkey prompt appears
contactInfo_loggedIn_notPrompted.mp4

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

hajinsuha1 and others added 24 commits February 17, 2026 12:53
…n components; add utility function for passkey error messages
…place deprecated error message function with a new utility for improved clarity and add handling for too many registration attempts.
…ude mappings for various error responses and ensure correct message descriptors are returned.
…able passkey login tests, handle user cancellation errors, and ensure proper rendering of UI elements during authentication.
…test clarity; mock configurations for passkey enabled/disabled scenarios, and ensure proper UI rendering during authentication processes.
…nents; replace showToast with showRegisterPasskeyToast for improved clarity and functionality. Update tests to validate passkey registration toast display after successful login, ensuring proper configuration checks and UI rendering.
… messages for unavailable features and authentication API errors. Update related tests to ensure correct message mappings for various error responses.
…fully, including early returns for 412 status. Improve passkey authentication error handling by adding console error logging in AuthModal and Login components.
…s components to standardize user feedback. Replace specific error messages with a generic "Something went wrong. Try again!" message. Update tests to reflect these changes and ensure consistent error handling in the UI.
… for clarity in the WebAuthn registration process.
- Introduced `abortPasskeyLogin` method to allow users to cancel ongoing passkey login requests.
- Integrated `AbortController` to manage cancellation of the passkey prompt when switching login methods.
- Updated tests to verify the new abort functionality and ensure correct parameters are passed to `navigator.credentials.get`.
…n/index.jsx

- Added `abortPasskeyLogin` to the login component to cleanly abort ongoing passkey login requests when navigating away.
- Updated tests to ensure the abort signal is correctly passed and handled during login attempts with different methods.
- Verified that the passkey prompt is aborted when the user logs in with a password or navigates away from the login page.
- Added `abortPasskeyLogin` to the AuthModal hook to ensure ongoing passkey login requests are aborted when the modal closes or the component unmounts.
- Enhanced tests to verify that the passkey prompt is correctly aborted when the modal is closed or when a user logs in with a password while the passkey prompt is active.
@hajinsuha1 hajinsuha1 added the skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated label Feb 23, 2026
@cc-prodsec
Copy link
Collaborator

cc-prodsec commented Feb 23, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

hajinsuha1 and others added 4 commits February 23, 2026 17:13
- Updated the login component to only prompt for passkey login when the user is not already signed in, improving user experience.
- Adjusted the dependency array in the `useEffect` hook to include `isRegistered`, ensuring the effect runs correctly based on the user's authentication state.
- Enhanced tests to verify that the passkey prompt does not trigger when the user is already registered.
…ancelled-after-user-logs-in

Signed-off-by: Jinsu Ha <91205717+hajinsuha1@users.noreply.github.com>
- Added `abortPasskeyLogin` to cleanly abort ongoing passkey login requests when the component unmounts or when the user logs in with a password.
- Updated the logic to only prompt for passkey login when the user is a guest, improving user experience.
- Enhanced tests to verify the correct behavior of the passkey login flow, including cleanup on unmount and handling user login transitions.
- Modified the logic to prompt for passkey login based on the `isGuest` state instead of `isRegistered`, enhancing user experience for guest users.
- Updated the dependency array in the `useEffect` hook to reflect the change in state management.
- Improved test isolation by clearing authentication state cookies after each test.
- Updated the logic to prompt for passkey login only when the user is on the contact info step, enhancing the user experience.
- Adjusted the dependency array in the `useEffect` hook to track the current step instead of the registration status.
- Enhanced tests to ensure correct behavior of passkey login prompts based on the current step in the checkout process.
@hajinsuha1 hajinsuha1 marked this pull request as ready for review February 24, 2026 19:31
@hajinsuha1 hajinsuha1 requested a review from a team as a code owner February 24, 2026 19:31
Comment on lines +194 to +198
if (isGuest) {
loginWithPasskey().catch(() => {
form.setError('global', {type: 'manual', message: formatMessage(API_ERROR_MESSAGE)})
})
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a bit of an edge case but previously when a user was logged in they could navigate to the /login page and it would prompt for a passkey before redirecting the user to the accounts page.

- Simplified the condition for rendering the AuthModal by removing unnecessary checks for customer data.
- Updated the welcome message to default to 'back' if the customer's first name is not available.
- Adjusted the dependency array in the `useEffect` hook to only track `isRegistered`.
- Enhanced tests to verify modal behavior during passkey login, ensuring proper assertions for modal visibility and user sign-in confirmation.
Comment on lines -273 to -274
// Also ensure that the customer data is loaded.
if (!isNowRegistered || !customer.data) {
Copy link
Collaborator Author

@hajinsuha1 hajinsuha1 Feb 24, 2026

Choose a reason for hiding this comment

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

this was merged in the previous PR but I am reverting it as it introduces a bug where the auth modal will be emtpy for a moment while it waits for the customer data to load.

bug.mp4

},
{
name: customer.data?.firstName || ''
name: customer.data?.firstName || 'back'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

small enhancement in case the customer is not loaded in time, to display "Welcome back," instead of "Welcome ,"

@hajinsuha1 hajinsuha1 merged commit e9050d7 into feature/webauthn-login Feb 26, 2026
42 checks passed
@hajinsuha1 hajinsuha1 deleted the W-21253277-passkey-login-cancelled-after-user-logs-in branch February 26, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants