diff --git a/auth/lib/services/user_service.dart b/auth/lib/services/user_service.dart index 4f58c670b15..d36196a541c 100644 --- a/auth/lib/services/user_service.dart +++ b/auth/lib/services/user_service.dart @@ -297,31 +297,41 @@ class UserService { await dialog.show(); try { final userPassword = _config.getVolatilePassword(); - if (userPassword == null) throw Exception("volatile password is null"); - await _saveConfiguration(response); - - Widget page; - if (_config.getEncryptedToken() != null) { - await _config.decryptSecretsAndGetKeyEncKey( - userPassword, - _config.getKeyAttributes()!, + if (userPassword == null) { + await dialog.hide(); + // ignore: unawaited_futures + Navigator.of(context).pushAndRemoveUntil( + MaterialPageRoute( + builder: (BuildContext context) { + return const PasswordReentryPage(); + }, + ), + (route) => route.isFirst, ); - page = const HomePage(); } else { - throw Exception("unexpected response during passkey verification"); - } - await dialog.hide(); + 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, - ); + // ignore: unawaited_futures + Navigator.of(context).pushAndRemoveUntil( + MaterialPageRoute( + builder: (BuildContext context) { + return page; + }, + ), + (route) => route.isFirst, + ); + } } catch (e) { _logger.severe(e); await dialog.hide(); @@ -351,9 +361,12 @@ class UserService { await dialog.hide(); if (response.statusCode == 200) { Widget page; + final String passkeySessionID = response.data["passkeySessionID"]; final String twoFASessionID = response.data["twoFactorSessionID"]; if (twoFASessionID.isNotEmpty) { page = TwoFactorAuthenticationPage(twoFASessionID); + } else if (passkeySessionID.isNotEmpty) { + page = PasskeyPage(passkeySessionID); } else { await _saveConfiguration(response); if (Configuration.instance.getEncryptedToken() != null) { diff --git a/auth/pubspec.yaml b/auth/pubspec.yaml index 94e8c9a3494..6a36132ab81 100644 --- a/auth/pubspec.yaml +++ b/auth/pubspec.yaml @@ -1,6 +1,6 @@ name: ente_auth description: ente two-factor authenticator -version: 3.0.11+311 +version: 3.0.12+312 publish_to: none environment: diff --git a/mobile/lib/services/user_service.dart b/mobile/lib/services/user_service.dart index 511627ba9a2..a6cb6562069 100644 --- a/mobile/lib/services/user_service.dart +++ b/mobile/lib/services/user_service.dart @@ -340,21 +340,31 @@ class UserService { await dialog.show(); try { final userPassword = Configuration.instance.getVolatilePassword(); - if (userPassword == null) throw Exception("volatile password is null"); - await _saveConfiguration(response); - - if (Configuration.instance.getEncryptedToken() != null) { - await Configuration.instance.decryptSecretsAndGetKeyEncKey( - userPassword, - Configuration.instance.getKeyAttributes()!, + if (userPassword == null) { + await dialog.hide(); + // ignore: unawaited_futures + Navigator.of(context).pushAndRemoveUntil( + MaterialPageRoute( + builder: (BuildContext context) { + return const PasswordReentryPage(); + }, + ), + (route) => route.isFirst, ); } else { - throw Exception("unexpected response during passkey verification"); + if (Configuration.instance.getEncryptedToken() != null) { + await Configuration.instance.decryptSecretsAndGetKeyEncKey( + userPassword, + Configuration.instance.getKeyAttributes()!, + ); + } else { + throw Exception("unexpected response during passkey verification"); + } + await dialog.hide(); + Navigator.of(context).popUntil((route) => route.isFirst); + Bus.instance.fire(AccountConfiguredEvent()); } - await dialog.hide(); - Navigator.of(context).popUntil((route) => route.isFirst); - Bus.instance.fire(AccountConfiguredEvent()); } catch (e) { _logger.severe(e); await dialog.hide(); @@ -384,10 +394,14 @@ class UserService { await dialog.hide(); if (response.statusCode == 200) { Widget page; + final String passkeySessionID = response.data["passkeySessionID"]; final String twoFASessionID = response.data["twoFactorSessionID"]; + if (twoFASessionID.isNotEmpty) { await setTwoFactor(value: true); page = TwoFactorAuthenticationPage(twoFASessionID); + } else if (passkeySessionID.isNotEmpty) { + page = PasskeyPage(passkeySessionID); } else { await _saveConfiguration(response); if (Configuration.instance.getEncryptedToken() != null) { diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml index 62c2a39352c..11c89b23538 100644 --- a/mobile/pubspec.yaml +++ b/mobile/pubspec.yaml @@ -12,7 +12,7 @@ description: ente photos application # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.8.138+658 +version: 0.8.139+659 publish_to: none environment: