authenticateUser static method

Future<AuthenticationDto?> authenticateUser(
  1. WardenType? localWardenType,
  2. WardenType remoteWardenType,
  3. String? passKey,
  4. WaterState stateType,
  5. int version,
  6. SchemaMetaData smd,
  7. SchemaMetaData smdSys,
  8. DbTransaction transaction,
  9. UserTools userTools,
  10. ConfigurationNameDefaults defaults,
)

Implementation

static Future<AuthenticationDto?> authenticateUser(
    WardenType? localWardenType,
    WardenType remoteWardenType,
    String? passKey,
    WaterState stateType,
    int version,
    SchemaMetaData smd,
    SchemaMetaData smdSys,
    DbTransaction transaction,
    UserTools userTools,
    ConfigurationNameDefaults defaults) async {
  late RemoteDto remoteDto;

  RestGetAuthenticationUtils informationUtils = RestGetAuthenticationUtils(
      localWardenType,
      remoteWardenType,
      smd,
      smdSys,
      transaction,
      userTools,
      defaults,
      null);
  await informationUtils.init();
  try {
    remoteDto =
        await informationUtils.requestAuthenticationFromServer(version);
  } on SqlException catch (e) {
    if (e.sqlExceptionEnum == SqlExceptionEnum.ENTRY_NOT_FOUND ||
        e.sqlExceptionEnum == SqlExceptionEnum.FAILED_UPDATE ||
        e.sqlExceptionEnum == SqlExceptionEnum.FAILED_SELECT)
      print("WS $e");
    else
      rethrow;
  }

  AuthenticationDto? authenticationDto;
  switch (remoteDto.water_table_id) {
    case RemoteStatusDto.C_TABLE_ID:
      RemoteStatusDto remoteStatusDto = remoteDto as RemoteStatusDto;

      print("jj=" + remoteStatusDto.toString());
      break;
    case AuthenticationDto.C_TABLE_ID:
      authenticationDto = remoteDto as AuthenticationDto;
      print("ww=" + authenticationDto.toString());
      break;
    default:
      print("UNKNOWN=" + remoteDto.water_table_name);
  }
  return authenticationDto;
}