biometricEnable method

Future<Response<T>> biometricEnable(
  1. bool enabled
)

Implementation

Future<Response<T>> biometricEnable(bool enabled) async {
  try {
    final auth = await _auth;
    final provider = Provider.from(auth?.provider);
    if (auth == null || !auth.isLoggedIn || !provider.isAllowBiometric) {
      return Response(
        status: Status.notSupported,
        error: "User not logged in with email or username!",
      );
    }

    if (enabled) {
      final response = await delegate.signInWithBiometric();
      if (!response.isSuccessful) {
        return Response(status: response.status, error: response.error);
      }
    }

    final value = await _update(
      id: auth.id,
      updateMode: true,
      updates: {AuthKeys.i.biometric: enabled},
    );

    return Response(status: Status.ok, data: value);
  } catch (error) {
    return Response(
      status: Status.failure,
      error: error.toString(),
    );
  }
}