Skip to content

Commit

Permalink
update biometrics to handle updated local_auth changes
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-CStack committed Sep 17, 2024
1 parent d765535 commit a43f240
Showing 1 changed file with 92 additions and 64 deletions.
156 changes: 92 additions & 64 deletions lib/utilities/biometrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,75 +58,103 @@ class Biometrics {
// debugPrint("availableSystems: $availableSystems");

//TODO properly handle caught exceptions
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 (availableSystems.contains(BiometricType.strong)) {
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,
);
}
} 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,
);
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

0 comments on commit a43f240

Please sign in to comment.