Refactor navigation and authentication flow

- Move navigation setup to AppRouter
- Prevent protected route logic to handle login 401
This commit is contained in:
yangdx
2025-03-19 19:08:09 +08:00
parent 0339273fe9
commit 99814b57d9
5 changed files with 75 additions and 46 deletions

View File

@@ -48,7 +48,7 @@ const LoginPage = () => {
toast.info(status.message)
}
navigate('/')
return; // Exit early, no need to set checkingAuth to false
return // Exit early, no need to set checkingAuth to false
}
} catch (error) {
console.error('Failed to check auth configuration:', error)
@@ -95,11 +95,17 @@ const LoginPage = () => {
} else {
toast.success(t('login.successMessage'))
}
// Navigate to home page after successful login
navigate('/')
} catch (error) {
console.error('Login failed...', error)
toast.error(t('login.errorInvalidCredentials'))
// Clear any existing auth state
useAuthStore.getState().logout()
// Clear local storage
localStorage.removeItem('LIGHTRAG-API-TOKEN')
} finally {
setLoading(false)
}