mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-27 11:16:45 +00:00
Implement async validation of domain field on recovering access
Co-authored-by: Inex Code <inex.code@selfprivacy.org>
This commit is contained in:
parent
0d0a3a4fee
commit
19bc780db1
|
@ -285,8 +285,9 @@
|
|||
},
|
||||
"recovering": {
|
||||
"recovery_main_header": "Connect to an existing server",
|
||||
"domain_recovery_description": "Enter a server domain you want to get access for",
|
||||
"domain_recovery_description": "Enter a server domain you want to get access for:",
|
||||
"domain_recover_placeholder": "Your domain",
|
||||
"domain_recover_error": "Server with such domain is not found",
|
||||
"method_select_description": "Select a recovery method:",
|
||||
"method_select_other_device": "I have access on another device",
|
||||
"method_select_recovery_key": "I have a recovery key",
|
||||
|
|
|
@ -288,6 +288,7 @@
|
|||
"recovery_main_header": "Подключиться к существующему серверу",
|
||||
"domain_recovery_description": "Введите домен, по которому вы хотите получить доступ к серверу:",
|
||||
"domain_recover_placeholder": "Домен",
|
||||
"domain_recover_error": "Не удалось найти сервер с таким доменом",
|
||||
"method_select_description": "Выберите способ входа:",
|
||||
"method_select_other_device": "У меня есть доступ на другом устройстве",
|
||||
"method_select_recovery_key": "У меня есть ключ восстановления",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:cubit_form/cubit_form.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:selfprivacy/logic/api_maps/server.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
||||
|
@ -22,10 +23,25 @@ class RecoveryDomainFormCubit extends FormCubit {
|
|||
zoneId: ""));
|
||||
}
|
||||
|
||||
// @override
|
||||
// FutureOr<bool> asyncValidation() async {
|
||||
// ; //var client =
|
||||
// }
|
||||
@override
|
||||
FutureOr<bool> asyncValidation() async {
|
||||
var api = ServerApi(
|
||||
hasLogger: false,
|
||||
isWithToken: false,
|
||||
overrideDomain: serverDomainField.state.value);
|
||||
|
||||
// API version doesn't require access token,
|
||||
// so if the entered domain is indeed valid
|
||||
// and the server by it is reachable, we will
|
||||
// be able to confirm the input
|
||||
|
||||
final bool domainValid = await api.getApiVersion() != null;
|
||||
if (!domainValid) {
|
||||
serverDomainField.setError("recovering.domain_recover_error".tr());
|
||||
}
|
||||
|
||||
return domainValid;
|
||||
}
|
||||
|
||||
final ServerInstallationCubit initializingCubit;
|
||||
late final FieldCubit<String> serverDomainField;
|
||||
|
|
|
@ -17,7 +17,7 @@ import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
|
|||
import 'package:selfprivacy/ui/components/brand_timer/brand_timer.dart';
|
||||
import 'package:selfprivacy/ui/components/progress_bar/progress_bar.dart';
|
||||
import 'package:selfprivacy/ui/pages/rootRoute.dart';
|
||||
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_method_select.dart';
|
||||
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_domain.dart';
|
||||
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
||||
|
||||
class InitializingPage extends StatelessWidget {
|
||||
|
@ -104,8 +104,8 @@ class InitializingPage extends StatelessWidget {
|
|||
child: BrandButton.text(
|
||||
title: 'basis.connect_to_existing'.tr(),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
materialRoute(RecoveryMethodSelect()));
|
||||
Navigator.of(context)
|
||||
.push(materialRoute(RecoveryDomain()));
|
||||
},
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue