π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile] Add TwoFactorType enum & pass it during recovery
Neeraj Gupta8f37af3985c8
diff --git a/mobile/lib/models/account/two_factor.dart b/mobile/lib/models/account/two_factor.dartnew file mode 100644index 0000000000..b43f88a0c2--- /dev/null+++ b/mobile/lib/models/account/two_factor.dart@@ -0,0 +1 @@+enum TwoFactorType { totp, passKey }diff --git a/mobile/lib/services/user_service.dart b/mobile/lib/services/user_service.dartindex 9389611da1..0ca57992de 100644--- a/mobile/lib/services/user_service.dart+++ b/mobile/lib/services/user_service.dart@@ -16,6 +16,7 @@ import "package:photos/events/account_configured_event.dart";import 'package:photos/events/two_factor_status_change_event.dart';import 'package:photos/events/user_details_changed_event.dart';import "package:photos/generated/l10n.dart";+import "package:photos/models/account/two_factor.dart";import "package:photos/models/api/user/srp.dart";import 'package:photos/models/delete_account.dart';import 'package:photos/models/key_attributes.dart';@@ -807,7 +808,11 @@ class UserService {}}- Future<void> recoverTwoFactor(BuildContext context, String sessionID) async {+ Future<void> recoverTwoFactor(+ BuildContext context,+ String sessionID,+ TwoFactorType type,+ ) async {final dialog = createProgressDialog(context, S.of(context).pleaseWait);await dialog.show();try {@@ -823,6 +828,7 @@ class UserService {MaterialPageRoute(builder: (BuildContext context) {return TwoFactorRecoveryPage(+ type,sessionID,response.data["encryptedSecret"],response.data["secretDecryptionNonce"],@@ -868,6 +874,7 @@ class UserService {Future<void> removeTwoFactor(BuildContext context,+ TwoFactorType type,String sessionID,String recoveryKey,String encryptedSecret,diff --git a/mobile/lib/ui/account/two_factor_authentication_page.dart b/mobile/lib/ui/account/two_factor_authentication_page.dartindex 2e88e72771..8dd71d0441 100644--- a/mobile/lib/ui/account/two_factor_authentication_page.dart+++ b/mobile/lib/ui/account/two_factor_authentication_page.dart@@ -1,6 +1,7 @@import 'package:flutter/material.dart';import 'package:flutter/services.dart';import "package:photos/generated/l10n.dart";+import "package:photos/models/account/two_factor.dart";import 'package:photos/services/user_service.dart';import 'package:photos/ui/lifecycle_event_handler.dart';import 'package:pinput/pin_put/pin_put.dart';@@ -124,7 +125,11 @@ class _TwoFactorAuthenticationPageStateGestureDetector(behavior: HitTestBehavior.opaque,onTap: () {- UserService.instance.recoverTwoFactor(context, widget.sessionID);+ UserService.instance.recoverTwoFactor(+ context,+ widget.sessionID,+ TwoFactorType.totp,+ );},child: Container(padding: const EdgeInsets.all(10),diff --git a/mobile/lib/ui/account/two_factor_recovery_page.dart b/mobile/lib/ui/account/two_factor_recovery_page.dartindex 7cab3d343e..1b9a4fd624 100644--- a/mobile/lib/ui/account/two_factor_recovery_page.dart+++ b/mobile/lib/ui/account/two_factor_recovery_page.dart@@ -2,6 +2,7 @@ import 'dart:ui';import 'package:flutter/material.dart';import "package:photos/generated/l10n.dart";+import "package:photos/models/account/two_factor.dart";import 'package:photos/services/user_service.dart';import 'package:photos/utils/dialog_util.dart';@@ -9,8 +10,10 @@ class TwoFactorRecoveryPage extends StatefulWidget {final String sessionID;final String encryptedSecret;final String secretDecryptionNonce;+ final TwoFactorType type;const TwoFactorRecoveryPage(+ this.type,this.sessionID,this.encryptedSecret,this.secretDecryptionNonce, {@@ -71,6 +74,7 @@ class _TwoFactorRecoveryPageState extends State<TwoFactorRecoveryPage> {? () async {await UserService.instance.removeTwoFactor(context,+ widget.type,widget.sessionID,_recoveryKey.text,widget.encryptedSecret,