From 4c1e33a264da7825a8d05e6016c2ee6b0b67e3f1 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 1 May 2020 10:56:57 +0200 Subject: [PATCH] Do delete user account --- lib/helpers/account_helper.dart | 9 +++++++++ .../account_settings/account_privacy_settings.dart | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/helpers/account_helper.dart b/lib/helpers/account_helper.dart index 939fb6c..e3121ba 100644 --- a/lib/helpers/account_helper.dart +++ b/lib/helpers/account_helper.dart @@ -147,4 +147,13 @@ class AccountHelper { await APIRequest(uri: "account/disconnect_all_devices", needLogin: true) .execWithThrow(); } + + /// Remove permanently a user account + /// + /// Throws in case of failure + static Future deleteAccount(String password) async { + await APIRequest(uri: "account/delete", needLogin: true) + .addString("password", password) + .execWithThrow(); + } } diff --git a/lib/ui/routes/account_settings/account_privacy_settings.dart b/lib/ui/routes/account_settings/account_privacy_settings.dart index 3ba1cac..aef3285 100644 --- a/lib/ui/routes/account_settings/account_privacy_settings.dart +++ b/lib/ui/routes/account_settings/account_privacy_settings.dart @@ -1,3 +1,4 @@ +import 'package:comunic/helpers/account_helper.dart'; import 'package:comunic/ui/dialogs/input_user_password_dialog.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/ui_utils.dart'; @@ -60,9 +61,10 @@ class __AccountPrivacyScreenState extends State<_AccountPrivacyScreen> { true) return; // Delete account - print("Delete account"); + await AccountHelper.deleteAccount(password); } catch (e, stack) { print("Could not delete user account! $e\n$stack"); + showSimpleSnack(context, tr("Could not delete your account!")); } } }