Merge pull request #1133 from danielaskdd/main
Fix: Resolve graph data reloading problem after login token expire
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="logo.png" />
|
<link rel="icon" type="image/svg+xml" href="logo.png" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Lightrag</title>
|
<title>Lightrag</title>
|
||||||
<script type="module" crossorigin src="/webui/assets/index-T7hdp_6t.js"></script>
|
<script type="module" crossorigin src="/webui/assets/index-4I5HV9Fr.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/webui/assets/index-BSOt8Nur.css">
|
<link rel="stylesheet" crossorigin href="/webui/assets/index-BSOt8Nur.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@@ -67,32 +67,31 @@ const ProtectedRoute = ({ children }: ProtectedRouteProps) => {
|
|||||||
}
|
}
|
||||||
}, [isAuthenticated])
|
}, [isAuthenticated])
|
||||||
|
|
||||||
// Show nothing while checking auth status
|
// Handle navigation when authentication status changes
|
||||||
if (isChecking) {
|
useEffect(() => {
|
||||||
return null
|
if (!isChecking && !isAuthenticated) {
|
||||||
|
const currentPath = window.location.hash.slice(1); // Remove the '#' from hash
|
||||||
|
const isLoginPage = currentPath === '/login';
|
||||||
|
|
||||||
|
if (!isLoginPage) {
|
||||||
|
// Use navigation service for redirection
|
||||||
|
console.log('Not authenticated, redirecting to login');
|
||||||
|
navigationService.navigateToLogin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [isChecking, isAuthenticated]);
|
||||||
|
|
||||||
|
// Show nothing while checking auth status or when not authenticated on login page
|
||||||
|
if (isChecking || (!isAuthenticated && window.location.hash.slice(1) === '/login')) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// After checking, if still not authenticated
|
// Show children only when authenticated
|
||||||
if (!isAuthenticated) {
|
if (!isAuthenticated) {
|
||||||
// Get current path and check if it's a direct access
|
return null;
|
||||||
const currentPath = window.location.hash.slice(1); // Remove the '#' from hash
|
|
||||||
const isLoginPage = currentPath === '/login';
|
|
||||||
|
|
||||||
// Skip redirect if already on login page
|
|
||||||
if (isLoginPage) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For non-login pages, handle state reset and navigation
|
|
||||||
if (!isLoginPage) {
|
|
||||||
// Use navigation service for redirection
|
|
||||||
console.log('Not authenticated, redirecting to login');
|
|
||||||
navigationService.navigateToLogin();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return <>{children}</>
|
return <>{children}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AppContent = () => {
|
const AppContent = () => {
|
||||||
|
@@ -27,6 +27,7 @@ class NavigationService {
|
|||||||
graphStore.setGraphDataFetchAttempted(false);
|
graphStore.setGraphDataFetchAttempted(false);
|
||||||
graphStore.setLabelsFetchAttempted(false);
|
graphStore.setLabelsFetchAttempted(false);
|
||||||
graphStore.setSigmaInstance(null);
|
graphStore.setSigmaInstance(null);
|
||||||
|
graphStore.setIsFetching(false); // Reset isFetching state to prevent data loading issues
|
||||||
|
|
||||||
// Reset backend state
|
// Reset backend state
|
||||||
useBackendState.getState().clear();
|
useBackendState.getState().clear();
|
||||||
|
Reference in New Issue
Block a user