Source Code added
This commit is contained in:
parent
800376eafd
commit
9efa9bc6dd
3912 changed files with 754770 additions and 2 deletions
24
mobile/lib/repositories/biometric.repository.dart
Normal file
24
mobile/lib/repositories/biometric.repository.dart
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
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());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue