π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[auth] Show Linux auth setup guide on unlock failure (#10907)
neeraj-pilot5c120aa2b7fb
diff --git a/mobile/apps/auth/changes/linux-system-auth-setup.md b/mobile/apps/auth/changes/linux-system-auth-setup.mdnew file mode 100644index 0000000000..6e29f6062f--- /dev/null+++ b/mobile/apps/auth/changes/linux-system-auth-setup.md@@ -0,0 +1 @@+- Improved Linux setup guidance when system authentication needs extra setup.diff --git a/mobile/packages/lock_screen/lib/local_authentication_service.dart b/mobile/packages/lock_screen/lib/local_authentication_service.dartindex ced13ac782..eb1992a632 100644--- a/mobile/packages/lock_screen/lib/local_authentication_service.dart+++ b/mobile/packages/lock_screen/lib/local_authentication_service.dart@@ -3,6 +3,7 @@ import 'dart:io';import 'package:ente_lock_screen/auth_util.dart';import 'package:ente_lock_screen/lock_screen_settings.dart';import 'package:ente_lock_screen/ui/app_lock.dart';+import 'package:ente_lock_screen/ui/local_authentication_unavailable_dialog.dart';import 'package:ente_lock_screen/ui/lock_screen_password.dart';import 'package:ente_lock_screen/ui/lock_screen_pin.dart';import 'package:ente_strings/ente_strings.dart';@@ -71,7 +72,10 @@ class LocalAuthenticationService {}if (localAuthUnavailableException != null) {if (context.mounted) {- showToast(context, localAuthUnavailableException.userMessage);+ await showLocalAuthenticationUnavailableMessage(+ context,+ localAuthUnavailableException,+ );}return false;}@@ -164,7 +168,7 @@ class LocalAuthenticationService {} on LocalAuthenticationUnavailableException catch (e, s) {logger.warning("System local authentication unavailable", e, s);if (context.mounted) {- showToast(context, e.userMessage);+ await showLocalAuthenticationUnavailableMessage(context, e);}} finally {if (!didEnableLockScreen) {diff --git a/mobile/packages/lock_screen/lib/ui/local_authentication_unavailable_dialog.dart b/mobile/packages/lock_screen/lib/ui/local_authentication_unavailable_dialog.dartnew file mode 100644index 0000000000..e7387d8b72--- /dev/null+++ b/mobile/packages/lock_screen/lib/ui/local_authentication_unavailable_dialog.dart@@ -0,0 +1,58 @@+import 'package:ente_lock_screen/auth_util.dart';+import 'package:ente_strings/ente_strings.dart';+import 'package:ente_ui/components/buttons/button_widget.dart';+import 'package:ente_ui/components/buttons/models/button_type.dart';+import 'package:ente_ui/components/dialog_widget.dart';+import 'package:ente_ui/utils/toast_util.dart';+import 'package:ente_utils/platform_util.dart';+import 'package:flutter/material.dart';++const linuxSystemAuthGuideUrl =+ 'https://ente.com/help/auth/troubleshooting/linux-system-auth';++bool shouldShowLinuxSystemAuthSetupGuide(+ LocalAuthenticationUnavailableException exception,+) {+ return exception.issue == LocalAuthUnavailableIssue.linuxSetupRequired;+}++Future<void> showLocalAuthenticationUnavailableMessage(+ BuildContext context,+ LocalAuthenticationUnavailableException exception, {+ VoidCallback? onOpenGuide,+}) async {+ if (shouldShowLinuxSystemAuthSetupGuide(exception)) {+ await showLinuxSystemAuthSetupDialog(context, onOpenGuide: onOpenGuide);+ return;+ }+ showToast(context, exception.userMessage);+}++Future<void> showLinuxSystemAuthSetupDialog(+ BuildContext context, {+ VoidCallback? onOpenGuide,+}) async {+ await showDialogWidget(+ context: context,+ title: pendingTranslation('Linux setup required'),+ body: pendingTranslation(+ 'To use device lock on Linux, Ente Auth needs a one-time system authentication setup. The guide includes setup steps for Flatpak, AppImage, and fingerprint prompts.',+ ),+ isDismissible: true,+ buttons: [+ ButtonWidget(+ buttonType: ButtonType.primary,+ labelText: pendingTranslation('Open guide'),+ isInAlert: true,+ onTap: () async {+ onOpenGuide?.call();+ await PlatformUtil.openWebView(+ context,+ pendingTranslation('Linux setup required'),+ linuxSystemAuthGuideUrl,+ );+ },+ ),+ ],+ );+}diff --git a/mobile/packages/lock_screen/lib/ui/lock_screen.dart b/mobile/packages/lock_screen/lib/ui/lock_screen.dartindex 0800dec29f..bdaf227f29 100644--- a/mobile/packages/lock_screen/lib/ui/lock_screen.dart+++ b/mobile/packages/lock_screen/lib/ui/lock_screen.dart@@ -6,6 +6,7 @@ import 'package:ente_configuration/base_configuration.dart';import 'package:ente_lock_screen/auth_util.dart';import 'package:ente_lock_screen/lock_screen_settings.dart';import 'package:ente_lock_screen/ui/app_lock.dart';+import 'package:ente_lock_screen/ui/local_authentication_unavailable_dialog.dart';import 'package:ente_strings/ente_strings.dart';import 'package:ente_ui/theme/ente_theme.dart';import 'package:ente_ui/utils/dialog_util.dart';@@ -36,6 +37,8 @@ class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver {final _lockscreenSetting = LockScreenSettings.instance;// Suppress auto-auth only for the initial manual presentation.bool _suppressAutoPrompt = false;+ // Opening the Linux setup guide can background the app; skip that resume.+ bool _suppressNextLifecyclePrompt = false;@overridevoid initState() {@@ -192,6 +195,11 @@ class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver {void didChangeAppLifecycleState(AppLifecycleState state) {_logger.info(state.toString());if (state == AppLifecycleState.resumed && !_isShowingLockScreen) {+ if (_suppressNextLifecyclePrompt) {+ _suppressNextLifecyclePrompt = false;+ _hasPlacedAppInBackground = false;+ return;+ }// This is triggered either when the lock screen is dismissed or when// the app is brought to foreground_hasPlacedAppInBackground = false;@@ -362,7 +370,13 @@ class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver {_isShowingLockScreen = false;_logger.warning("System local authentication unavailable", e, s);if (mounted) {- showToast(context, e.userMessage);+ await showLocalAuthenticationUnavailableMessage(+ context,+ e,+ onOpenGuide: () {+ _suppressNextLifecyclePrompt = true;+ },+ );}} catch (e, s) {_isShowingLockScreen = false;diff --git a/mobile/packages/lock_screen/lib/ui/lock_screen_options.dart b/mobile/packages/lock_screen/lib/ui/lock_screen_options.dartindex 28b43461ff..9bc4ef1afe 100644--- a/mobile/packages/lock_screen/lib/ui/lock_screen_options.dart+++ b/mobile/packages/lock_screen/lib/ui/lock_screen_options.dart@@ -4,6 +4,7 @@ import "dart:io";import "package:ente_lock_screen/local_authentication_service.dart";import "package:ente_lock_screen/lock_screen_settings.dart";import "package:ente_lock_screen/ui/app_lock.dart";+import "package:ente_lock_screen/ui/local_authentication_unavailable_dialog.dart";import "package:ente_lock_screen/ui/lock_screen_auto_lock.dart";import "package:ente_lock_screen/ui/lock_screen_password.dart";import "package:ente_lock_screen/ui/lock_screen_pin.dart";@@ -20,12 +21,8 @@ import "package:ente_ui/components/title_bar_title_widget.dart";import "package:ente_ui/components/title_bar_widget.dart";import "package:ente_ui/components/toggle_switch_widget.dart";import "package:ente_ui/theme/ente_theme.dart";-import "package:ente_utils/platform_util.dart";import "package:flutter/material.dart";-const _linuxSystemAuthGuideUrl =- "https://ente.com/help/auth/troubleshooting/linux-system-auth";-class LockScreenOptions extends StatefulWidget {const LockScreenOptions({super.key});@@ -75,28 +72,7 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {final linuxStatus = await LocalAuthenticationService.instance.getLinuxLocalAuthSetupStatus();if (Platform.isLinux && linuxStatus?.setupRequired == true) {- await showDialogWidget(- context: context,- title: pendingTranslation("Linux setup required"),- body: pendingTranslation(- "To use device lock on Linux, Ente Auth needs a one-time system authentication setup. The guide includes setup steps for Flatpak, AppImage, and fingerprint prompts.",- ),- isDismissible: true,- buttons: [- ButtonWidget(- buttonType: ButtonType.primary,- labelText: pendingTranslation("Open guide"),- isInAlert: true,- onTap: () async {- await PlatformUtil.openWebView(- context,- pendingTranslation("Linux setup required"),- _linuxSystemAuthGuideUrl,- );- },- ),- ],- );+ await showLinuxSystemAuthSetupDialog(context);await _initializeSettings();return;}diff --git a/mobile/packages/lock_screen/test/auth_util_test.dart b/mobile/packages/lock_screen/test/auth_util_test.dartindex 7ec4b63d54..555eb1f587 100644--- a/mobile/packages/lock_screen/test/auth_util_test.dart+++ b/mobile/packages/lock_screen/test/auth_util_test.dart@@ -1,4 +1,5 @@import 'package:ente_lock_screen/auth_util.dart';+import 'package:ente_lock_screen/ui/local_authentication_unavailable_dialog.dart';import 'package:flutter/services.dart';import 'package:flutter_test/flutter_test.dart';import 'package:local_auth/local_auth.dart';@@ -131,4 +132,30 @@ void main() {expect(exception, isNull);});});++ group("shouldShowLinuxSystemAuthSetupGuide", () {+ test("routes Linux setup-required failures to the guide dialog", () {+ expect(+ shouldShowLinuxSystemAuthSetupGuide(+ const LocalAuthenticationUnavailableException(+ issue: LocalAuthUnavailableIssue.linuxSetupRequired,+ code: "noCredentialsSet",+ ),+ ),+ isTrue,+ );+ });++ test("keeps generic local auth failures on toast guidance", () {+ expect(+ shouldShowLinuxSystemAuthSetupGuide(+ const LocalAuthenticationUnavailableException(+ issue: LocalAuthUnavailableIssue.notConfigured,+ code: "noCredentialsSet",+ ),+ ),+ isFalse,+ );+ });+ });}