new project stable version
This commit is contained in:
27
lib/domain/usecase/change_pin_usecase.dart
Normal file
27
lib/domain/usecase/change_pin_usecase.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user