Cleanup params
This commit is contained in:
parent
7faf459e3c
commit
68e5c0fac4
1 changed files with 20 additions and 0 deletions
20
index.tsx
20
index.tsx
|
|
@ -6,6 +6,26 @@ import { Toaster } from 'react-hot-toast';
|
|||
import App from './App';
|
||||
import { oidcConfig } from './src/config/oidc';
|
||||
|
||||
// Clean up stale OAuth params on page load (e.g., after logout redirect)
|
||||
// This prevents "No matching state found in storage" errors
|
||||
const cleanupStaleOAuthParams = () => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const hasOAuthParams = params.has('code') || params.has('state');
|
||||
|
||||
if (hasOAuthParams) {
|
||||
const state = params.get('state');
|
||||
// Check if there's a matching state in storage
|
||||
const hasMatchingState = state && localStorage.getItem(`oidc.${state}`);
|
||||
|
||||
if (!hasMatchingState) {
|
||||
// Stale params - clean them up
|
||||
window.history.replaceState({}, document.title, window.location.pathname);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cleanupStaleOAuthParams();
|
||||
|
||||
const rootElement = document.getElementById('root');
|
||||
if (!rootElement) {
|
||||
throw new Error("Could not find root element to mount to");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue