Improve authentication flow and navigation handling

- Replace never-resolving promise with rejection
- Remove unnecessary setTimeout in navigation
This commit is contained in:
yangdx
2025-03-23 01:39:43 +08:00
parent 176fd1e998
commit 3609dc5b26
2 changed files with 6 additions and 9 deletions

View File

@@ -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(

View File

@@ -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() {