immich/mobile/lib/repositories/biometric.repository.dart
shenlong e52b9d15b5
chore: bump dart sdk to 3.8 (#20355)
* chore: bump dart sdk to 3.8

* chore: make build

* make pigeon

* chore: format files

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
2025-07-28 14:04:03 -05:00

25 lines
1016 B
Dart

import 'package:easy_localization/easy_localization.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/models/auth/biometric_status.model.dart';
import 'package:local_auth/local_auth.dart';
final biometricRepositoryProvider = Provider((ref) => BiometricRepository(LocalAuthentication()));
class BiometricRepository {
final LocalAuthentication _localAuth;
const BiometricRepository(this._localAuth);
Future<BiometricStatus> getStatus() async {
final bool canAuthenticateWithBiometrics = await _localAuth.canCheckBiometrics;
final bool canAuthenticate = canAuthenticateWithBiometrics || await _localAuth.isDeviceSupported();
final availableBiometric = await _localAuth.getAvailableBiometrics();
return BiometricStatus(canAuthenticate: canAuthenticate, availableBiometrics: availableBiometric);
}
Future<bool> authenticate(String? message) async {
return _localAuth.authenticate(localizedReason: message ?? 'please_auth_to_access'.tr());
}
}