feat: Refactor sign-out method to use unified service call across repositories

This commit is contained in:
Achintha Isuru
2026-03-02 16:04:20 -05:00
parent 8497709356
commit e8b768b978
5 changed files with 22 additions and 17 deletions

View File

@@ -475,8 +475,7 @@ class StaffConnectorRepositoryImpl implements StaffConnectorRepository {
@override
Future<void> signOut() async {
try {
await _service.auth.signOut();
_service.clearCache();
await _service.signOut();
} catch (e) {
throw Exception('Error signing out: ${e.toString()}');
}

View File

@@ -224,8 +224,19 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin {
}
}
/// Signs out the current user from Firebase Auth and clears all session data.
Future<void> signOut() async {
try {
await auth.signOut();
_clearCache();
} catch (e) {
debugPrint('DataConnectService: Error signing out: $e');
rethrow;
}
}
/// Clears Cached Repositories and Session data.
void clearCache() {
void _clearCache() {
_reportsRepository = null;
_shiftsRepository = null;
_hubsRepository = null;