From a32e96899241339cd7ab3534c4aa5350fd10d43e Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 20 Feb 2021 09:35:03 +0100 Subject: [PATCH] Terms of use are not hard coded anymore --- lib/helpers/server_config_helper.dart | 1 + lib/main_dev.dart | 1 - lib/main_online.dart | 1 - lib/models/config.dart | 6 +----- lib/models/server_config.dart | 3 +++ lib/ui/routes/create_account_route.dart | 6 ++---- 6 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/helpers/server_config_helper.dart b/lib/helpers/server_config_helper.dart index 0341d30..818b233 100644 --- a/lib/helpers/server_config_helper.dart +++ b/lib/helpers/server_config_helper.dart @@ -23,6 +23,7 @@ class ServerConfigurationHelper { _config = ServerConfig( minSupportedMobileVersion: Version.parse(response["min_supported_mobile_version"]), + termsURL: response["terms_url"], passwordPolicy: PasswordPolicy( allowMailInPassword: passwordPolicy["allow_email_in_password"], allowNameInPassword: passwordPolicy["allow_name_in_password"], diff --git a/lib/main_dev.dart b/lib/main_dev.dart index 20b4b2b..be84057 100644 --- a/lib/main_dev.dart +++ b/lib/main_dev.dart @@ -24,7 +24,6 @@ void main() { apiServerUri: "/", apiServerSecure: false, clientName: "ComunicFlutter", - termsOfServicesURL: "http://devweb.local/comunic/current/about.php?cgu", )); HttpOverrides.global = new MyHttpOverride(); diff --git a/lib/main_online.dart b/lib/main_online.dart index 5c95189..2b44190 100644 --- a/lib/main_online.dart +++ b/lib/main_online.dart @@ -11,7 +11,6 @@ void main() { apiServerUri: "/", apiServerSecure: true, clientName: "ComunicFlutter", - termsOfServicesURL: "https://about.communiquons.org/about/terms/", )); subMain(); diff --git a/lib/models/config.dart b/lib/models/config.dart index 22ad856..315e94f 100644 --- a/lib/models/config.dart +++ b/lib/models/config.dart @@ -11,19 +11,15 @@ class Config { final bool apiServerSecure; final String clientName; - final String termsOfServicesURL; - const Config({ @required this.apiServerName, @required this.apiServerUri, @required this.apiServerSecure, @required this.clientName, - @required this.termsOfServicesURL, }) : assert(apiServerName != null), assert(apiServerUri != null), assert(apiServerSecure != null), - assert(clientName != null), - assert(termsOfServicesURL != null); + assert(clientName != null); /// Get and set static configuration static Config _config; diff --git a/lib/models/server_config.dart b/lib/models/server_config.dart index af39ceb..baf5367 100644 --- a/lib/models/server_config.dart +++ b/lib/models/server_config.dart @@ -59,14 +59,17 @@ class ServerDataConservationPolicy { class ServerConfig { final Version minSupportedMobileVersion; + final String termsURL; final PasswordPolicy passwordPolicy; final ServerDataConservationPolicy dataConservationPolicy; const ServerConfig({ @required this.minSupportedMobileVersion, + @required this.termsURL, @required this.passwordPolicy, @required this.dataConservationPolicy, }) : assert(minSupportedMobileVersion != null), + assert(termsURL != null), assert(passwordPolicy != null), assert(dataConservationPolicy != null); } diff --git a/lib/ui/routes/create_account_route.dart b/lib/ui/routes/create_account_route.dart index e5dfd7f..33bba7d 100644 --- a/lib/ui/routes/create_account_route.dart +++ b/lib/ui/routes/create_account_route.dart @@ -1,5 +1,5 @@ import 'package:comunic/helpers/account_helper.dart'; -import 'package:comunic/models/config.dart'; +import 'package:comunic/helpers/server_config_helper.dart'; import 'package:comunic/models/new_account.dart'; import 'package:comunic/ui/widgets/new_password_input_widget.dart'; import 'package:comunic/utils/input_utils.dart'; @@ -226,9 +226,7 @@ class __CreateAccountRouteBodyState extends State<_CreateAccountRouteBody> { _accountCreated(); } - void _openTOS() { - launch(config().termsOfServicesURL); - } + void _openTOS() => launch(ServerConfigurationHelper.config.termsURL); void _showCreateAccountError() async { await showCupertinoDialog(