mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 17:22:38 +02:00
Merge pull request #1380 from xclear-cast/codex/drop-tokenhandler-storagekey
fix(auth): remove redundant token storage write
This commit is contained in:
commit
a51755c512
2 changed files with 2 additions and 10 deletions
|
|
@ -8,11 +8,7 @@ export default function AuthCallbackPage() {
|
||||||
// TokenHandler uses useGlobalLoadingEffect to show the loading screen
|
// TokenHandler uses useGlobalLoadingEffect to show the loading screen
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
<TokenHandler
|
<TokenHandler redirectPath="/dashboard" tokenParamName="token" />
|
||||||
redirectPath="/dashboard"
|
|
||||||
tokenParamName="token"
|
|
||||||
storageKey="surfsense_bearer_token"
|
|
||||||
/>
|
|
||||||
</Suspense>
|
</Suspense>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import { trackLoginSuccess } from "@/lib/posthog/events";
|
||||||
interface TokenHandlerProps {
|
interface TokenHandlerProps {
|
||||||
redirectPath?: string; // Default path to redirect after storing token (if no saved path)
|
redirectPath?: string; // Default path to redirect after storing token (if no saved path)
|
||||||
tokenParamName?: string; // Name of the URL parameter containing the token
|
tokenParamName?: string; // Name of the URL parameter containing the token
|
||||||
storageKey?: string; // Key to use when storing in localStorage (kept for backwards compatibility)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -19,12 +18,10 @@ interface TokenHandlerProps {
|
||||||
*
|
*
|
||||||
* @param redirectPath - Default path to redirect after storing token (default: '/dashboard')
|
* @param redirectPath - Default path to redirect after storing token (default: '/dashboard')
|
||||||
* @param tokenParamName - Name of the URL parameter containing the token (default: 'token')
|
* @param tokenParamName - Name of the URL parameter containing the token (default: 'token')
|
||||||
* @param storageKey - Key to use when storing in localStorage (default: 'surfsense_bearer_token')
|
|
||||||
*/
|
*/
|
||||||
const TokenHandler = ({
|
const TokenHandler = ({
|
||||||
redirectPath = "/dashboard",
|
redirectPath = "/dashboard",
|
||||||
tokenParamName = "token",
|
tokenParamName = "token",
|
||||||
storageKey = "surfsense_bearer_token",
|
|
||||||
}: TokenHandlerProps) => {
|
}: TokenHandlerProps) => {
|
||||||
// Always show loading for this component - spinner animation won't reset
|
// Always show loading for this component - spinner animation won't reset
|
||||||
useGlobalLoadingEffect(true);
|
useGlobalLoadingEffect(true);
|
||||||
|
|
@ -45,7 +42,6 @@ const TokenHandler = ({
|
||||||
}
|
}
|
||||||
sessionStorage.removeItem("login_success_tracked");
|
sessionStorage.removeItem("login_success_tracked");
|
||||||
|
|
||||||
localStorage.setItem(storageKey, token);
|
|
||||||
setBearerToken(token);
|
setBearerToken(token);
|
||||||
|
|
||||||
if (refreshToken) {
|
if (refreshToken) {
|
||||||
|
|
@ -78,7 +74,7 @@ const TokenHandler = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
run();
|
run();
|
||||||
}, [tokenParamName, storageKey, redirectPath]);
|
}, [tokenParamName, redirectPath]);
|
||||||
|
|
||||||
// Return null - the global provider handles the loading UI
|
// Return null - the global provider handles the loading UI
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue