-
Notifications
You must be signed in to change notification settings - Fork 212
@W-21253277 Passkey login cancelled after user logs in or navigates away #3688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hajinsuha1
merged 34 commits into
feature/webauthn-login
from
W-21253277-passkey-login-cancelled-after-user-logs-in
Feb 26, 2026
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
3791b65
Implement error handling for login with passkey in AuthModal and Logi…
hajinsuha1 8ec8140
Refactor passkey error handling in AuthModal and Login components; re…
hajinsuha1 98d8950
Add unit tests for passkey error message handling in auth-utils; incl…
hajinsuha1 315e3a1
fix unit tests by removing mocking AuthHelpers
hajinsuha1 1f45c06
Refactor passkey login tests to improve clarity and functionality; en…
hajinsuha1 54d6043
Enhance passkey login tests by refining error handling and improving …
hajinsuha1 b16b759
add error handling in passkey registration. add console error for deb…
hajinsuha1 767acfc
Refactor passkey registration handling in AuthModal and related compo…
hajinsuha1 1199fc6
Enhance passkey error handling in auth-utils by introducing new error…
hajinsuha1 977e9ea
use preview version for commerce-sdk-react
hajinsuha1 bbc4071
Revert "use preview version for commerce-sdk-react"
hajinsuha1 7c727b2
Enhance usePasskeyLogin hook to handle specific error responses grace…
hajinsuha1 a9bda52
Merge branch 'feature/webauthn-login' into W-21056536-error-handling-…
hajinsuha1 2e64f70
Refactor passkey registration and authentication error handling acros…
hajinsuha1 ca9c030
Merge branch 'W-21056536-error-handling-passkey-registration-and-logi…
hajinsuha1 cc79b74
Update comments in PasskeyRegistrationModal to correct step numbering…
hajinsuha1 303ed13
Merge branch 'feature/webauthn-login' into W-21056536-error-handling-…
hajinsuha1 b6f7f4f
lint
hajinsuha1 529b703
increase bundle size
hajinsuha1 1bf6075
fix commerce-sdk-react unit tests
hajinsuha1 f80c954
Merge branch 'feature/webauthn-login' into W-21056536-error-handling-…
hajinsuha1 b4170ad
Add abort functionality to passkey login hook
hajinsuha1 c0dd5e9
Enhance passkey login handling with abort functionality in pages/logi…
hajinsuha1 0d38469
Implement abort functionality for passkey login in AuthModal
hajinsuha1 c4d0811
Refine passkey login behavior to prevent unnecessary prompts
hajinsuha1 3583b34
Merge branch 'feature/webauthn-login' into W-21253277-passkey-login-c…
hajinsuha1 9c8717a
Merge branch 'W-21253277-passkey-login-cancelled-after-user-logs-in' …
hajinsuha1 3254cf4
Enhance passkey login handling in ContactInfo component
hajinsuha1 41c6abd
Update login component to handle guest user state for passkey login
hajinsuha1 044b836
revert contact-info changes that are unnecessary
hajinsuha1 016aeff
Refactor passkey login logic in ContactInfo component
hajinsuha1 a330310
cleanup comments and tests
hajinsuha1 5714c0b
use registerUserToken instead of hardcoded access token in tests
hajinsuha1 75e59c8
Refactor AuthModal logic and improve tests
hajinsuha1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,7 +75,7 @@ export const AuthModal = ({ | |
| const customerId = useCustomerId() | ||
| const {isRegistered, customerType} = useCustomerType() | ||
| const prevAuthType = usePrevious(customerType) | ||
| const {loginWithPasskey} = usePasskeyLogin() | ||
| const {loginWithPasskey, abortPasskeyLogin} = usePasskeyLogin() | ||
| const customer = useCustomer( | ||
| {parameters: {customerId}}, | ||
| {enabled: !!customerId && isRegistered} | ||
|
|
@@ -242,6 +242,11 @@ export const AuthModal = ({ | |
| form.setError('global', {type: 'manual', message: formatMessage(API_ERROR_MESSAGE)}) | ||
| }) | ||
| } | ||
|
|
||
| // Cleanup: abort passkey login when modal closes or component unmounts | ||
| return () => { | ||
| abortPasskeyLogin() | ||
| } | ||
| }, [isOpen]) | ||
|
|
||
| // Auto-focus the first field in each form view | ||
|
|
@@ -270,8 +275,7 @@ export const AuthModal = ({ | |
| const isNowRegistered = | ||
| (isOpen || isOtpAuthOpen) && isRegistered && (loggingIn || registering) | ||
| // If the customer changed, but it's not because they logged in or registered. Do nothing. | ||
| // Also ensure that the customer data is loaded. | ||
| if (!isNowRegistered || !customer.data) { | ||
| if (!isNowRegistered) { | ||
| return | ||
| } | ||
|
|
||
|
|
@@ -292,7 +296,7 @@ export const AuthModal = ({ | |
| id: 'auth_modal.info.welcome_user' | ||
| }, | ||
| { | ||
| name: customer.data?.firstName || '' | ||
| name: customer.data?.firstName || 'back' | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ," |
||
| } | ||
| )}`, | ||
| description: `${formatMessage({ | ||
|
|
@@ -313,7 +317,7 @@ export const AuthModal = ({ | |
| // Execute action to be performed on successful registration | ||
| onRegistrationSuccess() | ||
| } | ||
| }, [isRegistered, customer.data]) | ||
| }, [isRegistered]) | ||
|
|
||
| const onBackToSignInClick = () => | ||
| initialView === PASSWORD_VIEW ? onClose() : setCurrentView(LOGIN_VIEW) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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