diff --git a/.changeset/little-clowns-tap.md b/.changeset/little-clowns-tap.md new file mode 100644 index 00000000..955e8b84 --- /dev/null +++ b/.changeset/little-clowns-tap.md @@ -0,0 +1,5 @@ +--- +'@asgardeo/react': patch +--- + +Fix auto login diff --git a/packages/react/src/AsgardeoReactClient.ts b/packages/react/src/AsgardeoReactClient.ts index 85d494f4..28ac48d6 100644 --- a/packages/react/src/AsgardeoReactClient.ts +++ b/packages/react/src/AsgardeoReactClient.ts @@ -415,8 +415,19 @@ class AsgardeoReactClient e const baseUrl: string = config?.baseUrl; if (config.platform === Platform.AsgardeoV2) { + // Read authId from URL params or sessionStorage + // This is needed to complete the OAuth flow after registration + const authIdFromUrl: string = new URL(window.location.href).searchParams.get('authId'); + const authIdFromStorage: string = sessionStorage.getItem('asgardeo_auth_id'); + const authId: string = authIdFromUrl || authIdFromStorage; + + if (authIdFromUrl && !authIdFromStorage) { + sessionStorage.setItem('asgardeo_auth_id', authIdFromUrl); + } + return executeEmbeddedSignUpFlowV2({ baseUrl, + authId, payload: typeof firstArg === 'object' && 'flowType' in firstArg ? {...(firstArg as EmbeddedFlowExecuteRequestPayload), verbose: true} diff --git a/packages/react/src/components/presentation/auth/SignUp/v2/SignUp.tsx b/packages/react/src/components/presentation/auth/SignUp/v2/SignUp.tsx index c3f733d1..df16eede 100644 --- a/packages/react/src/components/presentation/auth/SignUp/v2/SignUp.tsx +++ b/packages/react/src/components/presentation/auth/SignUp/v2/SignUp.tsx @@ -89,6 +89,14 @@ const SignUp: FC = ({ const handleComplete = (response: EmbeddedFlowExecuteResponse) => { onComplete?.(response); + // Check if OAuth flow completed and we have a redirect URL with authorization code + // This happens when registration completes with assertion and OAuth authorize succeeds + const oauthRedirectUrl = (response as any)?.redirectUrl; + if (shouldRedirectAfterSignUp && oauthRedirectUrl) { + window.location.href = oauthRedirectUrl; + return; + } + // For non-redirection responses (regular sign-up completion), handle redirect if configured if (shouldRedirectAfterSignUp && response?.type !== EmbeddedFlowResponseType.Redirection && afterSignUpUrl) { window.location.href = afterSignUpUrl;