Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/little-clowns-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@asgardeo/react': patch
---

Fix auto login
11 changes: 11 additions & 0 deletions packages/react/src/AsgardeoReactClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,19 @@ class AsgardeoReactClient<T extends AsgardeoReactConfig = AsgardeoReactConfig> 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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ const SignUp: FC<SignUpProps> = ({
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;
Expand Down
Loading