Daniel.y commited on
Commit
11c9628
·
unverified ·
2 Parent(s): 06b9891 e1dbde8

Merge pull request #1133 from danielaskdd/main

Browse files

Fix: Resolve graph data reloading problem after login token expire

lightrag/api/webui/assets/{index-T7hdp_6t.js → index-4I5HV9Fr.js} RENAMED
Binary files a/lightrag/api/webui/assets/index-T7hdp_6t.js and b/lightrag/api/webui/assets/index-4I5HV9Fr.js differ
 
lightrag/api/webui/index.html CHANGED
Binary files a/lightrag/api/webui/index.html and b/lightrag/api/webui/index.html differ
 
lightrag_webui/src/AppRouter.tsx CHANGED
@@ -67,32 +67,31 @@ const ProtectedRoute = ({ children }: ProtectedRouteProps) => {
67
  }
68
  }, [isAuthenticated])
69
 
70
- // Show nothing while checking auth status
71
- if (isChecking) {
72
- return null
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
 
75
- // After checking, if still not authenticated
76
  if (!isAuthenticated) {
77
- // Get current path and check if it's a direct access
78
- const currentPath = window.location.hash.slice(1); // Remove the '#' from hash
79
- const isLoginPage = currentPath === '/login';
80
-
81
- // Skip redirect if already on login page
82
- if (isLoginPage) {
83
- return null;
84
- }
85
-
86
- // For non-login pages, handle state reset and navigation
87
- if (!isLoginPage) {
88
- // Use navigation service for redirection
89
- console.log('Not authenticated, redirecting to login');
90
- navigationService.navigateToLogin();
91
- return null;
92
- }
93
  }
94
 
95
- return <>{children}</>
96
  }
97
 
98
  const AppContent = () => {
 
67
  }
68
  }, [isAuthenticated])
69
 
70
+ // Handle navigation when authentication status changes
71
+ useEffect(() => {
72
+ if (!isChecking && !isAuthenticated) {
73
+ const currentPath = window.location.hash.slice(1); // Remove the '#' from hash
74
+ const isLoginPage = currentPath === '/login';
75
+
76
+ if (!isLoginPage) {
77
+ // Use navigation service for redirection
78
+ console.log('Not authenticated, redirecting to login');
79
+ navigationService.navigateToLogin();
80
+ }
81
+ }
82
+ }, [isChecking, isAuthenticated]);
83
+
84
+ // Show nothing while checking auth status or when not authenticated on login page
85
+ if (isChecking || (!isAuthenticated && window.location.hash.slice(1) === '/login')) {
86
+ return null;
87
  }
88
 
89
+ // Show children only when authenticated
90
  if (!isAuthenticated) {
91
+ return null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
93
 
94
+ return <>{children}</>;
95
  }
96
 
97
  const AppContent = () => {
lightrag_webui/src/services/navigation.ts CHANGED
@@ -27,6 +27,7 @@ class NavigationService {
27
  graphStore.setGraphDataFetchAttempted(false);
28
  graphStore.setLabelsFetchAttempted(false);
29
  graphStore.setSigmaInstance(null);
 
30
 
31
  // Reset backend state
32
  useBackendState.getState().clear();
 
27
  graphStore.setGraphDataFetchAttempted(false);
28
  graphStore.setLabelsFetchAttempted(false);
29
  graphStore.setSigmaInstance(null);
30
+ graphStore.setIsFetching(false); // Reset isFetching state to prevent data loading issues
31
 
32
  // Reset backend state
33
  useBackendState.getState().clear();