π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Restore password error sheets and support
r4khuld4cf62b51b3a
diff --git a/mobile/apps/photos/lib/core/configuration.dart b/mobile/apps/photos/lib/core/configuration.dartindex 7f35117f89..0ecf90a9bb 100644--- a/mobile/apps/photos/lib/core/configuration.dart+++ b/mobile/apps/photos/lib/core/configuration.dart@@ -12,6 +12,7 @@ import 'package:ente_pure_utils/ente_pure_utils.dart';import "package:flutter/services.dart";import 'package:flutter_cache_manager/flutter_cache_manager.dart';import 'package:flutter_secure_storage/flutter_secure_storage.dart';+import 'package:flutter_sodium/flutter_sodium.dart' show SodiumException;import 'package:logging/logging.dart';import 'package:path_provider/path_provider.dart';import "package:photos/app_mode.dart";@@ -20,6 +21,7 @@ import 'package:photos/core/cache/thumbnail_in_memory_cache.dart';import 'package:photos/core/cache/video_cache_manager.dart';import 'package:photos/core/constants.dart';import 'package:photos/core/error-reporting/super_logging.dart';+import 'package:photos/core/errors.dart';import 'package:photos/core/event_bus.dart';import 'package:photos/db/collections_db.dart';import 'package:photos/db/files_db.dart';@@ -420,16 +422,20 @@ class Configuration implements LockScreenHost, AccountDeletionHost {attributes.opsLimit!,);+ final encryptedKey = CryptoUtil.base642bin(attributes.encryptedKey);+ final keyDecryptionNonce = CryptoUtil.base642bin(+ attributes.keyDecryptionNonce,+ );Uint8List key;try {key = CryptoUtil.decryptSync(- CryptoUtil.base642bin(attributes.encryptedKey),+ encryptedKey,keyEncryptionKey,- CryptoUtil.base642bin(attributes.keyDecryptionNonce),+ keyDecryptionNonce,);- } catch (e) {+ } on SodiumException catch (e) {_logger.warning('master-key decryption failed: $e');- throw Exception("Incorrect password");+ throw IncorrectPasswordError();}await setKey(CryptoUtil.bin2base64(key));final secretKey = CryptoUtil.decryptSync(diff --git a/mobile/apps/photos/lib/core/errors.dart b/mobile/apps/photos/lib/core/errors.dartindex d6645bd813..cdd9fa3b7f 100644--- a/mobile/apps/photos/lib/core/errors.dart+++ b/mobile/apps/photos/lib/core/errors.dart@@ -89,6 +89,11 @@ class InvalidStateError extends AssertionError {class SrpSetupNotCompleteError extends Error {}+class IncorrectPasswordError implements Exception {+ @override+ String toString() => "Incorrect password";+}+class SharingNotPermittedForFreeAccountsError extends Error {}class RecipientIdentityMismatchError extends Error {}diff --git a/mobile/apps/photos/lib/ui/account/login_pwd_verification_page.dart b/mobile/apps/photos/lib/ui/account/login_pwd_verification_page.dartindex aae19fa5d2..fbf1ea82a3 100644--- a/mobile/apps/photos/lib/ui/account/login_pwd_verification_page.dart+++ b/mobile/apps/photos/lib/ui/account/login_pwd_verification_page.dart@@ -144,6 +144,9 @@ class _LoginPasswordVerificationPageState}Future<void> verifyPassword(BuildContext context, String password) async {+ setState(() {+ _isPasswordIncorrect = false;+ });final dialog = createProgressDialog(context,context.strings.pleaseWait,@@ -165,10 +168,15 @@ class _LoginPasswordVerificationPageStateawait dialog.hide();if (e.response != null && e.response!.statusCode == 401) {_logger.severe('server reject, failed verify SRP login', e, s);- if (!mounted) return;+ if (!mounted || !context.mounted) return;setState(() {_isPasswordIncorrect = true;});+ await _showContactSupportDialog(+ context,+ context.strings.incorrectPasswordTitle,+ context.strings.pleaseTryAgain,+ );} else {_logger.severe('API failure during SRP login ${e.type}', e, s);if (e.type == DioExceptionType.connectionTimeout ||diff --git a/mobile/apps/photos/lib/ui/account/password_reentry_page.dart b/mobile/apps/photos/lib/ui/account/password_reentry_page.dartindex 799de553df..6ca25ce242 100644--- a/mobile/apps/photos/lib/ui/account/password_reentry_page.dart+++ b/mobile/apps/photos/lib/ui/account/password_reentry_page.dart@@ -18,6 +18,7 @@ import 'package:photos/ui/components/buttons/button_widget.dart'show ButtonAction;import 'package:photos/ui/tabs/home_widget.dart';import 'package:photos/utils/dialog_util.dart';+import 'package:photos/utils/email_util.dart';class PasswordReentryPage extends StatefulWidget {const PasswordReentryPage({super.key});@@ -80,6 +81,9 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {Future<void> verifyPassword(String password) async {FocusScope.of(context).unfocus();+ setState(() {+ _isPasswordIncorrect = false;+ });final dialog = createProgressDialog(context, context.strings.pleaseWait);await dialog.show();try {@@ -111,13 +115,26 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {);}return;- } catch (e) {- _logger.warning("Password verification failed: $e");+ } on IncorrectPasswordError catch (e, s) {+ _logger.warning("Password verification failed", e, s);await dialog.hide();if (!mounted) return;setState(() {_isPasswordIncorrect = true;});+ await _showContactSupportDialog(+ context.strings.incorrectPasswordTitle,+ context.strings.pleaseTryAgain,+ );+ return;+ } catch (e, s) {+ _logger.severe("Password verification failed", e, s);+ await dialog.hide();+ if (!mounted) return;+ await _showContactSupportDialog(+ context.strings.somethingWentWrong,+ context.strings.verificationFailedPleaseTryAgain,+ );return;}await dialog.hide();@@ -137,6 +154,24 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {);}+ Future<void> _showContactSupportDialog(String title, String message) async {+ final dialogChoice = await showChoiceDialog(+ context,+ title: title,+ body: message,+ firstButtonLabel: context.strings.contactSupport,+ secondButtonLabel: context.strings.ok,+ );+ if (dialogChoice?.action == ButtonAction.first && mounted) {+ await sendLogs(+ context,+ context.strings.contactSupport,+ "[email protected]",+ postShare: () {},+ );+ }+ }+Future<void> _registerSRPForExistingUsers(Uint8List key) async {bool shouldSetupSRP = false;try {