chore: Remove unused ApiTokenvalidatoin

This commit is contained in:
NaiJi 2023-06-19 14:42:48 -03:00
parent 0502e68cc1
commit e418a58e5b
8 changed files with 9 additions and 36 deletions

View file

@ -19,9 +19,6 @@ class DigitalOceanDnsApi extends DnsProviderApi {
final String? customToken;
RegExp getApiTokenValidation() =>
RegExp(r'\s+|[!$%^&*()@+|~=`{}\[\]:<>?,.\/]');
@override
BaseOptions get options {
final BaseOptions options = BaseOptions(

View file

@ -98,12 +98,6 @@ class HetznerApi extends ServerProviderApi with VolumeProviderApi {
);
}
ProviderApiTokenValidation getApiTokenValidation() =>
ProviderApiTokenValidation(
regexp: RegExp(r'\s+|[-!$%^&*()@+|~=`{}\[\]:<>?,.\/]'),
length: 64,
);
Future<GenericResult<double?>> getPricePerGb() async {
double? price;

View file

@ -1,15 +1,6 @@
import 'package:selfprivacy/logic/api_maps/rest_maps/api_map.dart';
export 'package:selfprivacy/logic/api_maps/generic_result.dart';
class ProviderApiTokenValidation {
ProviderApiTokenValidation({
required this.length,
required this.regexp,
});
final int length;
final RegExp regexp;
}
abstract class ServerProviderApi extends ApiMap {
/// Provider name key which lets infect understand what kind of installation
/// it requires, for example 'digitaloceal' for Digital Ocean

View file

@ -6,13 +6,10 @@ import 'package:selfprivacy/logic/cubit/server_installation/server_installation_
class ServerProviderFormCubit extends FormCubit {
ServerProviderFormCubit(this.serverInstallationCubit) {
//final int tokenLength =
// serverInstallationCubit.serverProviderApiTokenValidation().length;
apiKey = FieldCubit(
initalValue: '',
validations: [
RequiredStringValidation('validations.required'.tr()),
//LengthStringNotEqualValidation(tokenLength),
],
);

View file

@ -227,6 +227,15 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
final ServerHostingDetails serverDetails,
) async {
await repository.saveServerDetails(serverDetails);
await ProvidersController.currentDnsProvider!.removeDomainRecords(
ip4: serverDetails.ip4,
domain: state.serverDomain!,
);
await ProvidersController.currentDnsProvider!.createDomainRecords(
ip4: serverDetails.ip4,
domain: state.serverDomain!,
);
emit(
(state as ServerInstallationNotFinished).copyWith(
isLoading: false,
@ -248,7 +257,6 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
serverTypeId: state.serverTypeIdentificator!,
errorCallback: clearAppConfig,
successCallback: onCreateServerSuccess,
dnsProvider: ProvidersController.currentDnsProvider!,
);
final result =

View file

@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:dio/dio.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/foundation.dart';
import 'package:hive/hive.dart';
@ -22,7 +21,6 @@ import 'package:selfprivacy/logic/models/json/device_token.dart';
import 'package:selfprivacy/logic/models/server_basic_info.dart';
import 'package:selfprivacy/logic/models/server_type.dart';
import 'package:selfprivacy/logic/providers/providers_controller.dart';
import 'package:selfprivacy/ui/helpers/modals.dart';
import 'package:selfprivacy/utils/network_utils.dart';
class IpNotFoundException implements Exception {

View file

@ -1,14 +1,12 @@
import 'package:selfprivacy/logic/models/hive/server_details.dart';
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
import 'package:selfprivacy/logic/models/hive/user.dart';
import 'package:selfprivacy/logic/providers/dns_providers/dns_provider.dart';
class LaunchInstallationData {
LaunchInstallationData({
required this.rootUser,
required this.dnsApiToken,
required this.dnsProviderType,
required this.dnsProvider,
required this.serverDomain,
required this.serverTypeId,
required this.errorCallback,
@ -19,7 +17,6 @@ class LaunchInstallationData {
final String dnsApiToken;
final ServerDomain serverDomain;
final DnsProviderType dnsProviderType;
final DnsProvider dnsProvider;
final String serverTypeId;
final Function() errorCallback;
final Function(ServerHostingDetails details) successCallback;

View file

@ -588,15 +588,6 @@ class HetznerServerProvider extends ServerProvider {
}
await installationData.successCallback(serverDetails);
await installationData.dnsProvider.removeDomainRecords(
ip4: serverDetails.ip4,
domain: installationData.serverDomain,
);
await installationData.dnsProvider.createDomainRecords(
ip4: serverDetails.ip4,
domain: installationData.serverDomain,
);
return GenericResult(success: true, data: null);
}