Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bio fix #994

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 26 additions & 97 deletions lib/utilities/biometrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,115 +46,44 @@ class Biometrics {
final canCheckBiometrics = await localAuth.canCheckBiometrics;
final isDeviceSupported = await localAuth.isDeviceSupported();

//todo: check if print needed
// debugPrint("canCheckBiometrics: $canCheckBiometrics");
// debugPrint("isDeviceSupported: $isDeviceSupported");

if (canCheckBiometrics && isDeviceSupported) {
final List<BiometricType> availableSystems =
List<BiometricType> availableSystems =
await localAuth.getAvailableBiometrics();

//todo: check if print needed
// debugPrint("availableSystems: $availableSystems");
Logging.instance.log(
"Bio availableSystems: $availableSystems",
level: LogLevel.Info,
);

//TODO properly handle caught exceptions
if (availableSystems.contains(BiometricType.strong)) {
try {
final bool didAuthenticate = await localAuth.authenticate(
localizedReason: localizedReason,
options: const AuthenticationOptions(
stickyAuth: true,
biometricOnly: true,
try {
final bool didAuthenticate = await localAuth.authenticate(
localizedReason: localizedReason,
options: const AuthenticationOptions(
stickyAuth: true,
biometricOnly: true,
),
authMessages: <AuthMessages>[
AndroidAuthMessages(
biometricHint: "",
cancelButton: cancelButtonText,
signInTitle: title,
),
authMessages: <AuthMessages>[
AndroidAuthMessages(
biometricHint: "",
cancelButton: cancelButtonText,
signInTitle: title,
),
],
);
],
);

if (didAuthenticate) {
return true;
}
} catch (e) {
Logging.instance.log(
"local_auth exception caught in Biometrics.authenticate(), e: $e",
level: LogLevel.Error,
);
if (didAuthenticate) {
return true;
}
} catch (e) {
Logging.instance.log(
"local_auth exception caught in Biometrics.authenticate(), e: $e",
level: LogLevel.Error,
);
}

// if (Platform.isIOS) {
// if (availableSystems.contains(BiometricType.face)) {
// try {
// final bool didAuthenticate = await localAuth.authenticate(
// localizedReason: localizedReason,
// options: const AuthenticationOptions(
// stickyAuth: true,
// biometricOnly: true,
// ),
// );
//
// if (didAuthenticate) {
// return true;
// }
// } catch (e) {
// Logging.instance.log(
// "local_auth exception caught in Biometrics.authenticate(), e: $e",
// level: LogLevel.Error,
// );
// }
// } else if (availableSystems.contains(BiometricType.fingerprint)) {
// try {
// final bool didAuthenticate = await localAuth.authenticate(
// localizedReason: localizedReason,
// options: const AuthenticationOptions(
// stickyAuth: true,
// biometricOnly: true,
// ),
// );
//
// if (didAuthenticate) {
// return true;
// }
// } catch (e) {
// Logging.instance.log(
// "local_auth exception caught in Biometrics.authenticate(), e: $e",
// level: LogLevel.Error,
// );
// }
// }
// } else if (Platform.isAndroid) {
// if (availableSystems.contains(BiometricType.fingerprint)) {
// try {
// final bool didAuthenticate = await localAuth.authenticate(
// localizedReason: localizedReason,
// options: const AuthenticationOptions(
// stickyAuth: true,
// biometricOnly: true,
// ),
// authMessages: <AuthMessages>[
// AndroidAuthMessages(
// biometricHint: "",
// cancelButton: cancelButtonText,
// signInTitle: title,
// ),
// ],
// );
//
// if (didAuthenticate) {
// return true;
// }
// } catch (e) {
// Logging.instance.log(
// "local_auth exception caught in Biometrics.authenticate(), e: $e",
// level: LogLevel.Error,
// );
// }
// }
// }
}

// authentication failed
Expand Down
Loading