Files
be_happy_public/lib/domain/usecase/change_pin_usecase.dart
2026-05-12 12:02:40 +03:00

28 lines
560 B
Dart

import 'package:be_happy/domain/repositories/pin_repository.dart';
import '../repositories/auth_repository.dart';
class ChangePinUseCase {
final PinRepository repository;
ChangePinUseCase(this.repository);
Future<void> call({
required String oldPin,
required String newPin,
}) async {
final savedPin = await repository.getSavedPin();
if (savedPin != oldPin) {
throw Exception('Wrong old PIN');
}
if (newPin.length != 6) {
throw Exception('Invalid new PIN');
}
await repository.savePin(newPin);
}
}