verifyBackUpCode method

Future<SessionResponse<User>> verifyBackUpCode({
  1. required String code,
  2. bool trustDevice = false,
  3. bool disableSession = false,
})

Verify backup code

code The backup code trustDevice If true, the device will be trusted for 30 days. It'll be refreshed on every sign in request within this time. disableSession If true, the session cookie will not be set.

Implementation

Future<SessionResponse<User>> verifyBackUpCode({
  required String code,
  bool trustDevice = false,
  bool disableSession = false,
}) async {
  try {
    final response = await dio.post(
      "/two-factor/verify-backup-code",
      data: {"code": code, "trustDevice": trustDevice, "disableSession": disableSession},
      options: await super.getOptions(),
    );
    return SessionResponse.fromJson(response.data, User.fromJson);
  } catch (e) {
    final message = getErrorMessage(e);
    if (message == null) rethrow;
    throw message;
  }
}