π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix legacy entry auth and PDF code wrapping
Neeraj Gupta21354d77234f
diff --git a/mobile/apps/locker/lib/ui/utils/legacy_utils.dart b/mobile/apps/locker/lib/ui/utils/legacy_utils.dartindex 9281acb0fa..a243aa5768 100644--- a/mobile/apps/locker/lib/ui/utils/legacy_utils.dart+++ b/mobile/apps/locker/lib/ui/utils/legacy_utils.dart@@ -2,41 +2,48 @@import "package:ente_legacy/pages/emergency_page.dart";import "package:ente_lock_screen/local_authentication_service.dart";-import "package:flutter/foundation.dart";import "package:flutter/material.dart";import "package:locker/l10n/l10n.dart";import "package:locker/services/configuration.dart";/// Opens the Legacy (Emergency contacts) page after authenticating the user.-///-/// In debug mode, authentication is bypassed.Future<void> openLegacyPage(BuildContext context) async {- var hasAuthenticatedForLegacyFlow = kDebugMode;- if (!hasAuthenticatedForLegacyFlow) {- hasAuthenticatedForLegacyFlow =- await LocalAuthenticationService.instance.requestLocalAuthentication(- context,- context.l10n.authToManageLegacy,- );- }- if (hasAuthenticatedForLegacyFlow && context.mounted) {- await Navigator.of(context).push(- MaterialPageRoute(- builder: (BuildContext context) {- return EmergencyPage(- config: Configuration.instance,- legacyKitAuthenticator: (context, reason) async {- if (hasAuthenticatedForLegacyFlow) {- return true;- }- hasAuthenticatedForLegacyFlow = await LocalAuthenticationService- .instance- .requestLocalAuthentication(context, reason);- return hasAuthenticatedForLegacyFlow;- },- );- },- ),- );+ var hasAuthenticatedForLegacyFlow = await _authenticateForLegacyFlow(+ context,+ context.l10n.authToManageLegacy,+ );+ if (!hasAuthenticatedForLegacyFlow || !context.mounted) {+ return;}++ await Navigator.of(context).push(+ MaterialPageRoute(+ builder: (BuildContext context) {+ return EmergencyPage(+ config: Configuration.instance,+ legacyKitAuthenticator: (context, reason) async {+ if (hasAuthenticatedForLegacyFlow) {+ return true;+ }+ hasAuthenticatedForLegacyFlow = await _authenticateForLegacyFlow(+ context,+ reason,+ );+ return hasAuthenticatedForLegacyFlow;+ },+ );+ },+ ),+ );+}++Future<bool> _authenticateForLegacyFlow(+ BuildContext context,+ String reason,+) {+ return LocalAuthenticationService.instance.requestLocalAuthentication(+ context,+ reason,+ useDebugAuthCache: false,+ );}diff --git a/mobile/packages/legacy/lib/services/legacy_kit_pdf_service.dart b/mobile/packages/legacy/lib/services/legacy_kit_pdf_service.dartindex 0bec8d8216..ab515cc10b 100644--- a/mobile/packages/legacy/lib/services/legacy_kit_pdf_service.dart+++ b/mobile/packages/legacy/lib/services/legacy_kit_pdf_service.dart@@ -669,7 +669,7 @@ class LegacyKitPdfService {}String _displayCopyCode(String copyCode) {- const chunkSize = 36;+ const chunkSize = 30;final compactCode = copyCode.replaceAll(RegExp(r"\s+"), "");final chunks = <String>[];for (var index = 0; index < compactCode.length; index += chunkSize) {diff --git a/mobile/packages/lock_screen/lib/local_authentication_service.dart b/mobile/packages/lock_screen/lib/local_authentication_service.dartindex 3ba48c7ceb..f946b2723b 100644--- a/mobile/packages/lock_screen/lib/local_authentication_service.dart+++ b/mobile/packages/lock_screen/lib/local_authentication_service.dart@@ -27,8 +27,9 @@ class LocalAuthenticationService {BuildContext context,String infoMessage, {bool refocusWindows = true,+ bool useDebugAuthCache = true,}) async {- if (kDebugMode) {+ if (kDebugMode && useDebugAuthCache) {// if last auth time is less than 60 seconds, don't ask for auth againif (lastAuthTime != 0 &&DateTime.now().millisecondsSinceEpoch - lastAuthTime < 60000) {@@ -44,9 +45,9 @@ class LocalAuthenticationService {macOSReason: context.strings.unlock,isAuthenticatingForInAppChange: true,);- AppLock.of(context)!.setEnabled(- await LockScreenSettings.instance.shouldShowLockScreen(),- );+ AppLock.of(+ context,+ )!.setEnabled(await LockScreenSettings.instance.shouldShowLockScreen());if (refocusWindows) {await PlatformUtil.refocusWindows();}@@ -54,7 +55,9 @@ class LocalAuthenticationService {showToast(context, infoMessage);return false;} else {- lastAuthTime = DateTime.now().millisecondsSinceEpoch;+ if (useDebugAuthCache) {+ lastAuthTime = DateTime.now().millisecondsSinceEpoch;+ }return true;}}@@ -121,21 +124,18 @@ class LocalAuthenticationService {);if (result) {AppLock.of(context)!.setEnabled(shouldEnableLockScreen);- await LockScreenSettings.instance- .setSystemLockScreen(shouldEnableLockScreen);+ await LockScreenSettings.instance.setSystemLockScreen(+ shouldEnableLockScreen,+ );return true;} else {- AppLock.of(context)!.setEnabled(- await LockScreenSettings.instance.shouldShowLockScreen(),- );+ AppLock.of(+ context,+ )!.setEnabled(await LockScreenSettings.instance.shouldShowLockScreen());}} else {// ignore: unawaited_futures- showErrorDialog(- context,- errorDialogTitle,- errorDialogContent,- );+ showErrorDialog(context, errorDialogTitle, errorDialogContent);}return false;}