@passkeyme/react-auth 2.2.7 → 2.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6693,8 +6693,12 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
6693
6693
  window.history.replaceState({}, document.title, window.location.pathname);
6694
6694
  setTimeout(async () => {
6695
6695
  const currentUser = state.authenticatedUser || user;
6696
- if (onSuccess && currentUser) {
6697
- // For custom callbacks, parent component handles navigation
6696
+ // If custom onSuccess callback provided, use it and let parent handle navigation
6697
+ if (onSuccess) {
6698
+ if (!currentUser) {
6699
+ debugLog(config, "CallbackHandler", "Warning: onSuccess provided but no currentUser available");
6700
+ return;
6701
+ }
6698
6702
  try {
6699
6703
  const token = await auth.getAccessToken();
6700
6704
  onSuccess(currentUser, token || "");
@@ -6703,11 +6707,18 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
6703
6707
  debugLog(config, "CallbackHandler", "Error getting access token:", error);
6704
6708
  onSuccess(currentUser, "");
6705
6709
  }
6710
+ return; // Don't proceed with redirect - parent handles navigation
6706
6711
  }
6707
- else {
6708
- // For redirects, navigate to success page
6712
+ // No custom callback - use successRedirect for navigation
6713
+ if (successRedirect) {
6714
+ console.log("[CallbackHandler] Redirecting to success URL:", {
6715
+ successRedirect,
6716
+ });
6709
6717
  window.location.href = successRedirect;
6710
6718
  }
6719
+ else {
6720
+ debugLog(config, "CallbackHandler", "No successRedirect or onSuccess provided - user will remain on callback page");
6721
+ }
6711
6722
  }, 100);
6712
6723
  };
6713
6724
  React.useEffect(() => {