diff --git a/assets/translations/en.json b/assets/translations/en.json index 46cee9b8..c0e95639 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -259,6 +259,9 @@ "1": "Connect a server", "2": "A place where your data and SelfPrivacy services will reside:", "how": "How to obtain API token", + "hetzner_bad_key_error": "Hetzner API key is invalid", + "cloudflare_bad_key_error": "Cloudflare API key is invalid", + "backblaze_bad_key_error": "Backblaze storage information is invalid", "3": "Connect CloudFlare", "4": "To manage your domain's DNS", "5": "CloudFlare API Token", diff --git a/assets/translations/ru.json b/assets/translations/ru.json index 68665e26..e2048024 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -260,6 +260,9 @@ "1": "Подключите сервер", "2": "Здесь будут жить наши данные и SelfPrivacy-сервисы", "how": "Как получить API Token", + "hetzner_bad_key_error": "Hetzner API ключ неверен", + "cloudflare_bad_key_error": "Cloudflare API ключ неверен", + "backblaze_bad_key_error": "Информация о Backblaze хранилище неверна", "3": "Подключите CloudFlare", "4": "Для управления DNS вашего домена", "5": "CloudFlare API Token", diff --git a/lib/logic/cubit/forms/setup/initializing/backblaze_form_cubit.dart b/lib/logic/cubit/forms/setup/initializing/backblaze_form_cubit.dart index 4769286d..04d2993e 100644 --- a/lib/logic/cubit/forms/setup/initializing/backblaze_form_cubit.dart +++ b/lib/logic/cubit/forms/setup/initializing/backblaze_form_cubit.dart @@ -55,10 +55,11 @@ class BackblazeFormCubit extends FormCubit { } if (!isKeyValid) { - keyId.setError('bad key'); - applicationKey.setError('bad key'); + keyId.setError('initializing.backblaze_bad_key_error'.tr()); + applicationKey.setError('initializing.backblaze_bad_key_error'.tr()); return false; } + return true; } } diff --git a/lib/logic/cubit/forms/setup/initializing/cloudflare_form_cubit.dart b/lib/logic/cubit/forms/setup/initializing/cloudflare_form_cubit.dart index 01d26835..6a4b3b30 100644 --- a/lib/logic/cubit/forms/setup/initializing/cloudflare_form_cubit.dart +++ b/lib/logic/cubit/forms/setup/initializing/cloudflare_form_cubit.dart @@ -42,12 +42,14 @@ class CloudFlareFormCubit extends FormCubit { isKeyValid = await apiClient.isValid(apiKey.state.value); } catch (e) { addError(e); + isKeyValid = false; } if (!isKeyValid) { - apiKey.setError('bad key'); + apiKey.setError('initializing.cloudflare_bad_key_error'.tr()); return false; } + return true; } } diff --git a/lib/logic/cubit/forms/setup/initializing/hetzner_form_cubit.dart b/lib/logic/cubit/forms/setup/initializing/hetzner_form_cubit.dart index b8f47e10..11465d9d 100644 --- a/lib/logic/cubit/forms/setup/initializing/hetzner_form_cubit.dart +++ b/lib/logic/cubit/forms/setup/initializing/hetzner_form_cubit.dart @@ -42,12 +42,14 @@ class HetznerFormCubit extends FormCubit { isKeyValid = await apiClient.isValid(apiKey.state.value); } catch (e) { addError(e); + isKeyValid = false; } if (!isKeyValid) { - apiKey.setError('bad key'); + apiKey.setError('initializing.hetzner_bad_key_error'.tr()); return false; } + return true; } } diff --git a/lib/logic/cubit/server_installation/server_installation_repository.dart b/lib/logic/cubit/server_installation/server_installation_repository.dart index 5d4db8fe..2a0f84f4 100644 --- a/lib/logic/cubit/server_installation/server_installation_repository.dart +++ b/lib/logic/cubit/server_installation/server_installation_repository.dart @@ -242,13 +242,18 @@ class ServerInstallationRepository { domainName: domainName, ); - final ServerHostingDetails? serverDetails = - await hetznerApi.createServer( - cloudFlareKey: cloudFlareKey, - rootUser: rootUser, - domainName: domainName, - dataBase: dataBase, - ); + ServerHostingDetails? serverDetails; + try { + serverDetails = await hetznerApi.createServer( + cloudFlareKey: cloudFlareKey, + rootUser: rootUser, + domainName: domainName, + dataBase: dataBase, + ); + } catch (e) { + print(e); + } + if (serverDetails == null) { print('Server is not initialized!'); return;