Refactor navigation and authentication flow
- Move navigation setup to AppRouter - Prevent protected route logic to handle login 401
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user