authWithOTP method

Future<RecordAuth> authWithOTP(
  1. String otpId,
  2. String password, {
  3. String? expand,
  4. String? fields,
  5. Map<String, dynamic> body = const {},
  6. Map<String, dynamic> query = const {},
  7. Map<String, String> headers = const {},
})

Authenticate an auth record via OTP.

On success this method automatically updates the client's AuthStore.

Implementation

Future<RecordAuth> authWithOTP(
  String otpId,
  String password, {
  String? expand,
  String? fields,
  Map<String, dynamic> body = const {},
  Map<String, dynamic> query = const {},
  Map<String, String> headers = const {},
}) {
  final enrichedBody = Map<String, dynamic>.of(body);
  enrichedBody["otpId"] ??= otpId;
  enrichedBody["password"] ??= password;

  final enrichedQuery = Map<String, dynamic>.of(query);
  enrichedQuery["expand"] ??= expand;
  enrichedQuery["fields"] ??= fields;

  return client
      .send<Map<String, dynamic>>(
        "$baseCollectionPath/auth-with-otp",
        method: "POST",
        body: enrichedBody,
        query: enrichedQuery,
        headers: headers,
      )
      .then(_authResponse);
}