From 3609dc5b26ead54eed6cf704ecb85bee6e76388b Mon Sep 17 00:00:00 2001 From: yangdx Date: Sun, 23 Mar 2025 01:39:43 +0800 Subject: [PATCH] Improve authentication flow and navigation handling - Replace never-resolving promise with rejection - Remove unnecessary setTimeout in navigation --- lightrag_webui/src/api/lightrag.ts | 5 +++-- lightrag_webui/src/services/navigation.ts | 10 +++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lightrag_webui/src/api/lightrag.ts b/lightrag_webui/src/api/lightrag.ts index 3b8b46f2..21da295a 100644 --- a/lightrag_webui/src/api/lightrag.ts +++ b/lightrag_webui/src/api/lightrag.ts @@ -186,8 +186,9 @@ axiosInstance.interceptors.response.use( } // For other APIs, navigate to login page navigationService.navigateToLogin(); - // Return a never-resolving promise to prevent further execution - return new Promise(() => {}); + + // return a reject Promise + return Promise.reject(new Error('Authentication required')); } throw new Error( `${error.response.status} ${error.response.statusText}\n${JSON.stringify( diff --git a/lightrag_webui/src/services/navigation.ts b/lightrag_webui/src/services/navigation.ts index d06c86c4..19da250e 100644 --- a/lightrag_webui/src/services/navigation.ts +++ b/lightrag_webui/src/services/navigation.ts @@ -67,14 +67,10 @@ class NavigationService { return; } - // First navigate to login page - this.navigate('/login'); + this.resetAllApplicationState(); + useAuthStore.getState().logout(); - // Then reset state after navigation - setTimeout(() => { - this.resetAllApplicationState(); - useAuthStore.getState().logout(); - }, 0); + this.navigate('/login'); } navigateToHome() {