Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

update locker delete accounts page

AmanRajSinghMourya2a1eea3d3ba7
diff --git a/mobile/apps/locker/lib/l10n/app_en.arb b/mobile/apps/locker/lib/l10n/app_en.arb
index 9f16b5c914..98cb403e01 100644
--- a/mobile/apps/locker/lib/l10n/app_en.arb
+++ b/mobile/apps/locker/lib/l10n/app_en.arb
@@ -1041,5 +1041,15 @@
"suggestions": "Suggestions",
"noResultsFound": "No results found",
"viewActiveSessions": "View active sessions",
- "authToViewYourActiveSessions": "Please authenticate to view your active sessions"
+ "authToViewYourActiveSessions": "Please authenticate to view your active sessions",
+ "deleteAccountFeedbackPrompt": "Something not working? Reach out at {email}, we'd love to help.",
+ "@deleteAccountFeedbackPrompt": {
+ "placeholders": {
+ "email": {
+ "type": "String"
+ }
+ }
+ },
+ "sendFeedback": "Send feedback",
+ "deleteAccountPermanentWarning": "This will permanently delete your Ente Auth, Photos, and Locker data"
}
diff --git a/mobile/apps/locker/lib/l10n/app_localizations.dart b/mobile/apps/locker/lib/l10n/app_localizations.dart
index 5b3764548c..09cbef55b8 100644
--- a/mobile/apps/locker/lib/l10n/app_localizations.dart
+++ b/mobile/apps/locker/lib/l10n/app_localizations.dart
@@ -3083,6 +3083,24 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Please authenticate to view your active sessions'**
String get authToViewYourActiveSessions;
+
+ /// No description provided for @deleteAccountFeedbackPrompt.
+ ///
+ /// In en, this message translates to:
+ /// **'Something not working? Reach out at {email}, we\'d love to help.'**
+ String deleteAccountFeedbackPrompt(String email);
+
+ /// No description provided for @sendFeedback.
+ ///
+ /// In en, this message translates to:
+ /// **'Send feedback'**
+ String get sendFeedback;
+
+ /// No description provided for @deleteAccountPermanentWarning.
+ ///
+ /// In en, this message translates to:
+ /// **'This will permanently delete your Ente Auth, Photos, and Locker data'**
+ String get deleteAccountPermanentWarning;
}
class _AppLocalizationsDelegate
diff --git a/mobile/apps/locker/lib/l10n/app_localizations_en.dart b/mobile/apps/locker/lib/l10n/app_localizations_en.dart
index 839b1da596..d813268dfc 100644
--- a/mobile/apps/locker/lib/l10n/app_localizations_en.dart
+++ b/mobile/apps/locker/lib/l10n/app_localizations_en.dart
@@ -1804,4 +1804,16 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get authToViewYourActiveSessions =>
'Please authenticate to view your active sessions';
+
+ @override
+ String deleteAccountFeedbackPrompt(String email) {
+ return 'Something not working? Reach out at $email, we\'d love to help.';
+ }
+
+ @override
+ String get sendFeedback => 'Send feedback';
+
+ @override
+ String get deleteAccountPermanentWarning =>
+ 'This will permanently delete your Ente Auth, Photos, and Locker data';
}
diff --git a/mobile/apps/locker/lib/ui/pages/delete_account_page.dart b/mobile/apps/locker/lib/ui/pages/delete_account_page.dart
new file mode 100644
index 0000000000..977470d9fc
--- /dev/null
+++ b/mobile/apps/locker/lib/ui/pages/delete_account_page.dart
@@ -0,0 +1,203 @@
+import "dart:convert";
+
+import "package:ente_accounts/ente_accounts.dart";
+import "package:ente_configuration/base_configuration.dart";
+import "package:ente_crypto_api/ente_crypto_api.dart";
+import "package:ente_lock_screen/local_authentication_service.dart";
+import "package:ente_strings/ente_strings.dart";
+import "package:ente_ui/components/alert_bottom_sheet.dart";
+import "package:ente_ui/theme/ente_theme.dart";
+import "package:ente_ui/utils/toast_util.dart";
+import "package:ente_utils/email_util.dart";
+import "package:flutter/material.dart";
+import "package:locker/l10n/l10n.dart";
+import "package:locker/ui/components/gradient_button.dart";
+
+class DeleteAccountPage extends StatelessWidget {
+ final BaseConfiguration config;
+
+ const DeleteAccountPage(
+ this.config, {
+ super.key,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final l10n = context.l10n;
+
+ return Scaffold(
+ backgroundColor: colorScheme.backgroundBase,
+ appBar: AppBar(
+ backgroundColor: colorScheme.backgroundBase,
+ surfaceTintColor: Colors.transparent,
+ toolbarHeight: 48,
+ leadingWidth: 48,
+ leading: GestureDetector(
+ onTap: () => Navigator.pop(context),
+ child: const Icon(Icons.arrow_back),
+ ),
+ ),
+ body: SafeArea(
+ child: Padding(
+ padding: const EdgeInsets.all(16),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ l10n.deleteAccount,
+ style: textTheme.h3Bold,
+ ),
+ const SizedBox(height: 24),
+ Center(
+ child: Image.asset(
+ "assets/file_delete_icon.png",
+ width: 115,
+ height: 104,
+ ),
+ ),
+ const SizedBox(height: 24),
+ RichText(
+ text: TextSpan(
+ children: [
+ TextSpan(
+ text: l10n
+ .deleteAccountFeedbackPrompt("[email protected]")
+ .split("[email protected]")[0],
+ ),
+ TextSpan(
+ style: TextStyle(color: colorScheme.primary700),
+ ),
+ TextSpan(
+ text: l10n
+ .deleteAccountFeedbackPrompt("[email protected]")
+ .split("[email protected]")[1],
+ ),
+ ],
+ style: textTheme.body.copyWith(
+ color: colorScheme.textMuted,
+ ),
+ ),
+ ),
+ const SizedBox(height: 16),
+ GradientButton(
+ text: l10n.sendFeedback,
+ onTap: () async {
+ await sendEmail(
+ context,
+ subject: "[Feedback]",
+ );
+ },
+ ),
+ const SizedBox(height: 24),
+ Text(
+ l10n.deleteAccountPermanentWarning,
+ style: textTheme.body.copyWith(
+ color: colorScheme.textMuted,
+ ),
+ ),
+ const SizedBox(height: 16),
+ GradientButton(
+ text: l10n.deleteAccount,
+ backgroundColor: colorScheme.warning700,
+ onTap: () async => {await _initiateDelete(context)},
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Future<void> _initiateDelete(BuildContext context) async {
+ final deleteChallengeResponse =
+ await UserService.instance.getDeleteChallenge(context);
+ if (deleteChallengeResponse == null) {
+ return;
+ }
+ if (deleteChallengeResponse.allowDelete) {
+ await _confirmAndDelete(context, deleteChallengeResponse);
+ } else {
+ await _requestEmailForDeletion(context);
+ }
+ }
+
+ Future<void> _confirmAndDelete(
+ BuildContext context,
+ DeleteChallengeResponse response,
+ ) async {
+ final hasAuthenticated =
+ await LocalAuthenticationService.instance.requestLocalAuthentication(
+ context,
+ context.strings.initiateAccountDeleteTitle,
+ );
+
+ if (hasAuthenticated) {
+ final confirmed = await _showDeleteConfirmationSheet(context);
+ if (confirmed != true) {
+ return;
+ }
+ final decryptChallenge = CryptoUtil.openSealSync(
+ CryptoUtil.base642bin(response.encryptedChallenge),
+ CryptoUtil.base642bin(
+ config.getKeyAttributes()!.publicKey,
+ ),
+ config.getSecretKey()!,
+ );
+ final challengeResponseStr = utf8.decode(decryptChallenge);
+ await UserService.instance.deleteAccount(context, challengeResponseStr);
+ if (!context.mounted) {
+ return;
+ }
+ showShortToast(context, context.strings.yourAccountHasBeenDeleted);
+ Navigator.of(context).popUntil((route) => route.isFirst);
+ }
+ }
+
+ Future<bool?> _showDeleteConfirmationSheet(BuildContext context) async {
+ final colorScheme = getEnteColorScheme(context);
+
+ return showAlertBottomSheet<bool>(
+ context,
+ title: context.strings.confirmAccountDeleteTitle,
+ message: context.strings.confirmAccountDeleteMessage,
+ assetPath: "assets/warning-grey.png",
+ buttons: [
+ GradientButton(
+ text: context.strings.delete,
+ backgroundColor: colorScheme.warning700,
+ onTap: () => Navigator.of(context).pop(true),
+ ),
+ ],
+ );
+ }
+
+ Future<void> _requestEmailForDeletion(BuildContext context) async {
+ final colorScheme = getEnteColorScheme(context);
+
+ await showAlertBottomSheet(
+ context,
+ title: context.strings.deleteAccount,
+ message:
+ "Please send an email to [email protected] from your registered email address.\n\nYour request will be processed within 72 hours.",
+ assetPath: "assets/file_delete_icon.png",
+ buttons: [
+ GradientButton(
+ text: context.strings.sendEmail,
+ backgroundColor: colorScheme.primary700,
+ onTap: () async {
+ Navigator.of(context).pop();
+ await sendEmail(
+ context,
+ subject: "[Delete account]",
+ );
+ },
+ ),
+ ],
+ );
+ }
+}
diff --git a/mobile/apps/locker/lib/ui/settings/pages/account_settings_page.dart b/mobile/apps/locker/lib/ui/settings/pages/account_settings_page.dart
index c50419e21e..551db0f74a 100644
--- a/mobile/apps/locker/lib/ui/settings/pages/account_settings_page.dart
+++ b/mobile/apps/locker/lib/ui/settings/pages/account_settings_page.dart
@@ -1,5 +1,4 @@
import "package:ente_accounts/pages/change_email_dialog.dart";
-import "package:ente_accounts/pages/delete_account_page.dart";
import "package:ente_accounts/pages/password_entry_page.dart";
import "package:ente_crypto_api/ente_crypto_api.dart";
import "package:ente_lock_screen/local_authentication_service.dart";
@@ -11,6 +10,7 @@ import "package:flutter/material.dart";
import "package:locker/l10n/l10n.dart";
import "package:locker/services/configuration.dart";
import "package:locker/ui/components/recovery_key_sheet.dart";
+import "package:locker/ui/pages/delete_account_page.dart";
import "package:locker/ui/pages/home_page.dart";
import "package:locker/ui/settings/widgets/settings_widget.dart";