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; final String? customToken;
RegExp getApiTokenValidation() =>
RegExp(r'\s+|[!$%^&*()@+|~=`{}\[\]:<>?,.\/]');
@override @override
BaseOptions get options { BaseOptions get options {
final BaseOptions options = BaseOptions( 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 { Future<GenericResult<double?>> getPricePerGb() async {
double? price; double? price;

View file

@ -1,15 +1,6 @@
import 'package:selfprivacy/logic/api_maps/rest_maps/api_map.dart'; import 'package:selfprivacy/logic/api_maps/rest_maps/api_map.dart';
export 'package:selfprivacy/logic/api_maps/generic_result.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 { abstract class ServerProviderApi extends ApiMap {
/// Provider name key which lets infect understand what kind of installation /// Provider name key which lets infect understand what kind of installation
/// it requires, for example 'digitaloceal' for Digital Ocean /// 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 { class ServerProviderFormCubit extends FormCubit {
ServerProviderFormCubit(this.serverInstallationCubit) { ServerProviderFormCubit(this.serverInstallationCubit) {
//final int tokenLength =
// serverInstallationCubit.serverProviderApiTokenValidation().length;
apiKey = FieldCubit( apiKey = FieldCubit(
initalValue: '', initalValue: '',
validations: [ validations: [
RequiredStringValidation('validations.required'.tr()), RequiredStringValidation('validations.required'.tr()),
//LengthStringNotEqualValidation(tokenLength),
], ],
); );

View file

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

View file

@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart'; import 'package:device_info_plus/device_info_plus.dart';
import 'package:dio/dio.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:hive/hive.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_basic_info.dart';
import 'package:selfprivacy/logic/models/server_type.dart'; import 'package:selfprivacy/logic/models/server_type.dart';
import 'package:selfprivacy/logic/providers/providers_controller.dart'; import 'package:selfprivacy/logic/providers/providers_controller.dart';
import 'package:selfprivacy/ui/helpers/modals.dart';
import 'package:selfprivacy/utils/network_utils.dart'; import 'package:selfprivacy/utils/network_utils.dart';
class IpNotFoundException implements Exception { 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_details.dart';
import 'package:selfprivacy/logic/models/hive/server_domain.dart'; import 'package:selfprivacy/logic/models/hive/server_domain.dart';
import 'package:selfprivacy/logic/models/hive/user.dart'; import 'package:selfprivacy/logic/models/hive/user.dart';
import 'package:selfprivacy/logic/providers/dns_providers/dns_provider.dart';
class LaunchInstallationData { class LaunchInstallationData {
LaunchInstallationData({ LaunchInstallationData({
required this.rootUser, required this.rootUser,
required this.dnsApiToken, required this.dnsApiToken,
required this.dnsProviderType, required this.dnsProviderType,
required this.dnsProvider,
required this.serverDomain, required this.serverDomain,
required this.serverTypeId, required this.serverTypeId,
required this.errorCallback, required this.errorCallback,
@ -19,7 +17,6 @@ class LaunchInstallationData {
final String dnsApiToken; final String dnsApiToken;
final ServerDomain serverDomain; final ServerDomain serverDomain;
final DnsProviderType dnsProviderType; final DnsProviderType dnsProviderType;
final DnsProvider dnsProvider;
final String serverTypeId; final String serverTypeId;
final Function() errorCallback; final Function() errorCallback;
final Function(ServerHostingDetails details) successCallback; final Function(ServerHostingDetails details) successCallback;

View file

@ -588,15 +588,6 @@ class HetznerServerProvider extends ServerProvider {
} }
await installationData.successCallback(serverDetails); 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); return GenericResult(success: true, data: null);
} }