fix: improve server connection handling during authentication

- Updated AuthStateManager to clear the active server ID upon logout, ensuring a proper return to the server connection page.
- Enhanced RouterNotifier to allow users to stay on the server connection page if authenticated, improving navigation flow.
- Modified AuthenticationPage to navigate back to the server connection page instead of popping the navigation stack, enhancing user experience during server setup.
This commit is contained in:
cogwheel0
2025-10-10 22:08:23 +05:30
parent c26ba02a88
commit 8ac71c5718
3 changed files with 13 additions and 2 deletions

View File

@@ -562,6 +562,10 @@ class AuthStateManager extends _$AuthStateManager {
await storage.clearAuthData();
_updateApiServiceToken(null);
// Clear active server to force return to server connection page
await storage.setActiveServerId(null);
ref.invalidate(activeServerProvider);
// Update state
_update(
(current) => current.copyWith(
@@ -577,6 +581,10 @@ class AuthStateManager extends _$AuthStateManager {
} catch (e) {
DebugLogger.error('logout-failed', scope: 'auth/state', error: e);
// Even if logout fails, clear local state
final storage = ref.read(optimizedStorageServiceProvider);
await storage.setActiveServerId(null);
ref.invalidate(activeServerProvider);
_update(
(current) => current.copyWith(
status: AuthStatus.unauthenticated,