π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
auth: delete account page
AmanRajSinghMouryaef1ab9dda8d9
diff --git a/mobile/packages/accounts/lib/models/delete_account.dart b/mobile/packages/accounts/lib/models/delete_account.dartdeleted file mode 100644index 9967afcfcf..0000000000--- a/mobile/packages/accounts/lib/models/delete_account.dart+++ /dev/null@@ -1,5 +0,0 @@-class DeleteChallengeResponse {- final String encryptedChallenge;-- DeleteChallengeResponse({required this.encryptedChallenge});-}diff --git a/mobile/packages/accounts/lib/pages/delete_account_page.dart b/mobile/packages/accounts/lib/pages/delete_account_page.dartdeleted file mode 100644index 664265bb94..0000000000--- a/mobile/packages/accounts/lib/pages/delete_account_page.dart+++ /dev/null@@ -1,170 +0,0 @@-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/buttons/gradient_button.dart';-import 'package:ente_ui/components/dialogs.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';--class DeleteAccountPage extends StatelessWidget {- final BaseConfiguration config;-- const DeleteAccountPage(this.config, {super.key});-- @override- Widget build(BuildContext context) {- return Scaffold(- appBar: AppBar(- elevation: 0,- title: Text(context.strings.deleteAccount),- leading: IconButton(- icon: const Icon(Icons.arrow_back),- color: Theme.of(context).iconTheme.color,- onPressed: () {- Navigator.of(context).pop();- },- ),- ),- body: Padding(- padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 24),- child: Center(- child: Column(- crossAxisAlignment: CrossAxisAlignment.center,- children: [- Image.asset('assets/broken_heart.png', width: 200),- const SizedBox(height: 24),- Center(- child: Text(- context.strings.deleteAccountQuery,- style: Theme.of(context).textTheme.titleMedium,- ),- ),- const SizedBox(height: 12),- RichText(- // textAlign: TextAlign.center,- text: TextSpan(- children: const [- TextSpan(text: "Please write to us at "),- TextSpan(- text: "[email protected]",- style: TextStyle(color: Color.fromRGBO(29, 185, 84, 1)),- ),- TextSpan(text: ", maybe there is a way we can help."),- ],- style: Theme.of(context).textTheme.titleMedium,- ),- ),- const SizedBox(height: 24),- GradientButton(- text: context.strings.yesSendFeedbackAction,- onTap: () async {- await sendEmail(- context,- to: '[email protected]',- subject: '[Feedback]',- );- },- ),- const Padding(padding: EdgeInsets.symmetric(vertical: 8)),- InkWell(- child: SizedBox(- width: double.infinity,- child: OutlinedButton.icon(- style: OutlinedButton.styleFrom(- shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(8),- ),- side: const BorderSide(color: Colors.redAccent),- padding: const EdgeInsets.symmetric(- vertical: 18,- horizontal: 10,- ),- backgroundColor: Colors.white,- ),- label: Text(- context.strings.noDeleteAccountAction,- style: const TextStyle(- color: Colors.redAccent, // same for both themes- ),- textAlign: TextAlign.center,- ),- onPressed: () async => {await _initiateDelete(context)},- icon: const Icon(- Icons.no_accounts,- color: Colors.redAccent,- ),- ),- ),- ),- const SizedBox(height: 16),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 8),- child: Text(- context.strings.deleteAccountWarning,- style: Theme.of(context).textTheme.bodyMedium?.copyWith(- color: Colors.redAccent,- fontWeight: FontWeight.w800,- ),- textAlign: TextAlign.center,- ),- ),- ],- ),- ),- ),- );- }-- Future<void> _initiateDelete(BuildContext context) async {- final deleteChallengeResponse = await UserService.instance- .getDeleteChallenge(context);- if (deleteChallengeResponse == null) {- return;- }- await _confirmAndDelete(context, deleteChallengeResponse);- }-- Future<void> _confirmAndDelete(- BuildContext context,- DeleteChallengeResponse response,- ) async {- final hasAuthenticated = await LocalAuthenticationService.instance- .requestLocalAuthentication(- context,- context.strings.initiateAccountDeleteTitle,- );-- if (hasAuthenticated) {- final choice = await showChoiceDialogOld(- context,- context.strings.confirmAccountDeleteTitle,- context.strings.confirmAccountDeleteMessage,- firstAction: context.strings.cancel,- secondAction: context.strings.delete,- firstActionColor: getEnteColorScheme(context).surface,- secondActionColor: Colors.red,- );- if (choice != DialogUserChoice.secondChoice) {- 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);- }- }-}