Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][auth] Fix passkey authn flow when emailVerification is enabled

Neeraj Gupta205feab4c23d
diff --git a/auth/lib/services/user_service.dart b/auth/lib/services/user_service.dart
index 4f58c670b1..d36196a541 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/mobile/lib/services/user_service.dart b/mobile/lib/services/user_service.dart
index 511627ba9a..a6cb656206 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) {