23 lines
798 B
Dart
23 lines
798 B
Dart
import '../../database/database.dart';
|
|
import '../cloud/account_cloud_cleanup_service.dart';
|
|
import 'auth_service.dart';
|
|
|
|
/// Coordinates destructive account work while preserving device-local rides.
|
|
class AccountLifecycleService {
|
|
final AuthService _auth;
|
|
final CloudAccountCleanup _cloud;
|
|
final AppDatabase _db;
|
|
|
|
AccountLifecycleService({required this._auth, required this._cloud, required this._db});
|
|
|
|
Future<void> deleteAccount({String? password}) async {
|
|
final user = _auth.currentUser;
|
|
if (user == null || user.isAnonymous) throw StateError('A permanent account is required.');
|
|
final uid = user.uid;
|
|
await _auth.reauthenticate(password: password);
|
|
await _cloud.deleteCloudData();
|
|
await _auth.deleteCurrentUser();
|
|
await _db.clearCloudOwnerUid(uid);
|
|
}
|
|
}
|