fix state management
This commit is contained in:
@@ -6,6 +6,9 @@ import Root from './Root';
|
||||
export default function App() {
|
||||
// @ts-ignore
|
||||
const globalState: Record<string, string> = window['__authorizer__'];
|
||||
if (globalState.state) {
|
||||
sessionStorage.setItem('authorizer_state', globalState.state);
|
||||
}
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
|
@@ -11,9 +11,14 @@ export default function Root() {
|
||||
|
||||
useEffect(() => {
|
||||
if (token) {
|
||||
const state = sessionStorage.getItem('authorizer_state')?.trim();
|
||||
const url = new URL(config.redirectURL || '/app');
|
||||
if (url.origin !== window.location.origin) {
|
||||
window.location.href = config.redirectURL || '/app';
|
||||
console.log({ x: `${config.redirectURL || '/app'}?state=${state}` });
|
||||
sessionStorage.removeItem('authorizer_state');
|
||||
window.location.replace(
|
||||
`${config.redirectURL || '/app'}?state=${state}`
|
||||
);
|
||||
}
|
||||
}
|
||||
return () => {};
|
||||
|
Reference in New Issue
Block a user