Refactor settings to use FirebaseAuth for sign out
Replaces the previous mock-based authentication in client settings with FirebaseAuth for sign out functionality. Updates dependencies and imports accordingly, and adds firebase_auth to the settings package and firebase_core to the client app. Also includes minor Dart type improvements and dependency reordering.
This commit is contained in:
@@ -1,19 +1,23 @@
|
||||
import 'package:krow_data_connect/krow_data_connect.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import '../../domain/repositories/settings_repository_interface.dart';
|
||||
|
||||
/// Implementation of [SettingsRepositoryInterface].
|
||||
///
|
||||
/// This implementation delegates data access to the [AuthRepositoryMock]
|
||||
/// from the `data_connect` package.
|
||||
/// This implementation delegates authentication operations to [FirebaseAuth].
|
||||
class SettingsRepositoryImpl implements SettingsRepositoryInterface {
|
||||
/// The auth mock from data connect.
|
||||
final AuthRepositoryMock mock;
|
||||
/// The Firebase Auth instance.
|
||||
final FirebaseAuth _firebaseAuth;
|
||||
|
||||
/// Creates a [SettingsRepositoryImpl] with the required [mock].
|
||||
SettingsRepositoryImpl({required this.mock});
|
||||
/// Creates a [SettingsRepositoryImpl] with the required [_firebaseAuth].
|
||||
SettingsRepositoryImpl({required FirebaseAuth firebaseAuth})
|
||||
: _firebaseAuth = firebaseAuth;
|
||||
|
||||
@override
|
||||
Future<void> signOut() {
|
||||
return mock.signOut();
|
||||
Future<void> signOut() async {
|
||||
try {
|
||||
await _firebaseAuth.signOut();
|
||||
} catch (e) {
|
||||
throw Exception('Error signing out: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user