addBiometric method
Future<Response<bool> >
addBiometric({
- required SignByBiometricCallback callback,
- BiometricConfig? config,
override
Implementation
@override
Future<Response<bool>> addBiometric({
required SignByBiometricCallback callback,
BiometricConfig? config,
}) async {
final auth = await _auth;
final provider = AuthProviders.from(auth?.provider);
if (auth != null && auth.isLoggedIn && provider.isAllowBiometric) {
try {
final response = await authHandler.signInWithBiometric(config: config);
if (response.isSuccessful) {
final biometric = await callback(auth.mBiometric);
return _update(
id: auth.id,
updateMode: true,
creates:
auth.copy(biometric: biometric?.name ?? auth.biometric).source,
updates: {
AuthKeys.i.biometric: biometric?.name,
},
).then((_) => Response(status: Status.ok, data: true));
} else {
return Response(
status: response.status,
exception: response.exception,
);
}
} catch (_) {
return Response(status: Status.failure, exception: _.toString());
}
} else {
return Response(
status: Status.notSupported,
exception: "User not logged in email or username!",
);
}
}