diff --git a/auth/lib/services/user_service.dart b/auth/lib/services/user_service.dart index 9294680598..bd411da47b 100644 --- a/auth/lib/services/user_service.dart +++ b/auth/lib/services/user_service.dart @@ -267,31 +267,41 @@ class UserService { } Future onPassKeyVerified(BuildContext context, Map response) async { - final userPassword = Configuration.instance.getVolatilePassword(); - if (userPassword == null) throw Exception("volatile password is null"); + final ProgressDialog dialog = + createProgressDialog(context, context.l10n.pleaseWait); + await dialog.show(); + try { + final userPassword = _config.getVolatilePassword(); + if (userPassword == null) throw Exception("volatile password is null"); - await _saveConfiguration(response); + await _saveConfiguration(response); - Widget page; - if (Configuration.instance.getEncryptedToken() != null) { - await Configuration.instance.decryptSecretsAndGetKeyEncKey( - userPassword, - Configuration.instance.getKeyAttributes()!, + Widget page; + if (_config.getEncryptedToken() != null) { + await _config.decryptSecretsAndGetKeyEncKey( + userPassword, + _config.getKeyAttributes()!, + ); + page = const HomePage(); + } else { + throw Exception("unexpected response during passkey verification"); + } + await dialog.hide(); + + // ignore: unawaited_futures + Navigator.of(context).pushAndRemoveUntil( + MaterialPageRoute( + builder: (BuildContext context) { + return page; + }, + ), + (route) => route.isFirst, ); - page = const HomePage(); - } else { - throw Exception("unexpected response during passkey verification"); + } catch (e) { + _logger.severe(e); + await dialog.hide(); + rethrow; } - - // ignore: unawaited_futures - Navigator.of(context).pushAndRemoveUntil( - MaterialPageRoute( - builder: (BuildContext context) { - return page; - }, - ), - (route) => route.isFirst, - ); } Future verifyEmail( diff --git a/auth/lib/ui/passkey_page.dart b/auth/lib/ui/passkey_page.dart index f04c0494e6..b27b9e3a7c 100644 --- a/auth/lib/ui/passkey_page.dart +++ b/auth/lib/ui/passkey_page.dart @@ -8,6 +8,7 @@ import 'package:ente_auth/services/user_service.dart'; import 'package:ente_auth/ui/components/buttons/button_widget.dart'; import 'package:ente_auth/ui/components/models/button_type.dart'; import 'package:ente_auth/utils/dialog_util.dart'; +import 'package:ente_auth/utils/toast_util.dart'; import 'package:flutter/material.dart'; import 'package:logging/logging.dart'; import 'package:url_launcher/url_launcher_string.dart'; @@ -61,6 +62,11 @@ class _PasskeyPageState extends State { } try { if (mounted && link.toLowerCase().startsWith("enteauth://passkey")) { + if (Configuration.instance.isLoggedIn()) { + _logger.info('ignored deeplink: already configured'); + showToast(context, 'Account is already configured.'); + return; + } final String? uri = Uri.parse(link).queryParameters['response']; String base64String = uri!.toString(); while (base64String.length % 4 != 0) { diff --git a/auth/macos/Runner/Info.plist b/auth/macos/Runner/Info.plist index 418d695c9f..b48ea505b9 100644 --- a/auth/macos/Runner/Info.plist +++ b/auth/macos/Runner/Info.plist @@ -38,6 +38,7 @@ CFBundleURLSchemes otpauth + enteauth