Skip to content

Commit cafece9

Browse files
committed
Update
1 parent 31deeec commit cafece9

File tree

1 file changed

+8
-21
lines changed
  • packages/react/src/components/presentation/SignIn/component-driven

1 file changed

+8
-21
lines changed

packages/react/src/components/presentation/SignIn/component-driven/SignIn.tsx

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ const SignIn: FC<SignInProps> = ({className, size = 'medium', onSuccess, onError
317317
return false;
318318
};
319319

320+
/**
321+
* Initialize the flow and handle cleanup of stale flow state.
322+
*/
320323
useEffect(() => {
321324
const storedFlowId = sessionStorage.getItem('asgardeo_flow_id');
322325
const urlParams = getUrlParams();
@@ -329,32 +332,16 @@ const SignIn: FC<SignInProps> = ({className, size = 'medium', onSuccess, onError
329332

330333
handleSessionDataKey(urlParams.sessionDataKey);
331334

335+
// Skip OAuth code processing
332336
if (urlParams.code) {
333-
const flowIdFromState = resolveFlowId(
334-
currentFlowId,
335-
urlParams.state,
336-
urlParams.flowId,
337-
storedFlowId,
338-
);
339-
340-
// Only process code if we have a valid flowId to use
341-
if (flowIdFromState) {
342-
setFlowId(flowIdFromState);
343-
setIsFlowInitialized(true);
344-
initializationAttemptedRef.current = true;
345-
// Clean up flowId from URL after setting it in state
346-
cleanupFlowUrlParams();
347-
} else {
348-
console.warn('[SignIn] OAuth code in URL but no valid flowId found. Cleaning up stale OAuth parameters.');
349-
cleanupOAuthUrlParams(true);
350-
}
351337
return;
352338
}
353339

354-
// If flowId is in URL or sessionStorage but no code and no active flow state
355-
if ((urlParams.flowId || storedFlowId) && !urlParams.code && !currentFlowId) {
340+
// If flowId is in URL or sessionStorage but no active flow state, clean it up
341+
// This handles stale flowIds from previous sessions or incomplete flows
342+
if ((urlParams.flowId || storedFlowId) && !currentFlowId) {
356343
console.warn(
357-
'[SignIn] FlowId in URL/sessionStorage but no active flow state detected. '
344+
'[SignIn] FlowId in URL/sessionStorage but no active flow state detected. Cleaning up stale flowId.'
358345
);
359346
setFlowId(null);
360347
sessionStorage.removeItem('asgardeo_flow_id');

0 commit comments

Comments
 (0)