Refactor navigation and authentication flow, prevent mounting login page multiple times
- Improved protected route handling - Enhanced direct login access detection - Centralized navigation logic - Optimized state reset process - Fixed logout navigation behavior
This commit is contained in:
@@ -2,7 +2,6 @@ import axios, { AxiosError } from 'axios'
|
||||
import { backendBaseUrl } from '@/lib/constants'
|
||||
import { errorMessage } from '@/lib/utils'
|
||||
import { useSettingsStore } from '@/stores/settings'
|
||||
import { useAuthStore } from '@/stores/state'
|
||||
import { navigationService } from '@/services/navigation'
|
||||
|
||||
// Types
|
||||
@@ -174,10 +173,6 @@ axiosInstance.interceptors.response.use(
|
||||
(error: AxiosError) => {
|
||||
if (error.response) {
|
||||
if (error.response?.status === 401) {
|
||||
localStorage.removeItem('LIGHTRAG-API-TOKEN');
|
||||
sessionStorage.clear();
|
||||
useAuthStore.getState().logout();
|
||||
|
||||
// Use navigation service to handle redirection
|
||||
navigationService.navigateToLogin();
|
||||
|
||||
|
Reference in New Issue
Block a user