mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 15:30:40 +00:00
[mobile] Add TwoFactorType enum & pass it during recovery
This commit is contained in:
parent
6e160dca43
commit
8f37af3985
1
mobile/lib/models/account/two_factor.dart
Normal file
1
mobile/lib/models/account/two_factor.dart
Normal file
@ -0,0 +1 @@
|
|||||||
|
enum TwoFactorType { totp, passKey }
|
@ -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/two_factor_status_change_event.dart';
|
||||||
import 'package:photos/events/user_details_changed_event.dart';
|
import 'package:photos/events/user_details_changed_event.dart';
|
||||||
import "package:photos/generated/l10n.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/api/user/srp.dart";
|
||||||
import 'package:photos/models/delete_account.dart';
|
import 'package:photos/models/delete_account.dart';
|
||||||
import 'package:photos/models/key_attributes.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);
|
final dialog = createProgressDialog(context, S.of(context).pleaseWait);
|
||||||
await dialog.show();
|
await dialog.show();
|
||||||
try {
|
try {
|
||||||
@ -823,6 +828,7 @@ class UserService {
|
|||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return TwoFactorRecoveryPage(
|
return TwoFactorRecoveryPage(
|
||||||
|
type,
|
||||||
sessionID,
|
sessionID,
|
||||||
response.data["encryptedSecret"],
|
response.data["encryptedSecret"],
|
||||||
response.data["secretDecryptionNonce"],
|
response.data["secretDecryptionNonce"],
|
||||||
@ -868,6 +874,7 @@ class UserService {
|
|||||||
|
|
||||||
Future<void> removeTwoFactor(
|
Future<void> removeTwoFactor(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
|
TwoFactorType type,
|
||||||
String sessionID,
|
String sessionID,
|
||||||
String recoveryKey,
|
String recoveryKey,
|
||||||
String encryptedSecret,
|
String encryptedSecret,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import "package:photos/generated/l10n.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/services/user_service.dart';
|
||||||
import 'package:photos/ui/lifecycle_event_handler.dart';
|
import 'package:photos/ui/lifecycle_event_handler.dart';
|
||||||
import 'package:pinput/pin_put/pin_put.dart';
|
import 'package:pinput/pin_put/pin_put.dart';
|
||||||
@ -124,7 +125,11 @@ class _TwoFactorAuthenticationPageState
|
|||||||
GestureDetector(
|
GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
UserService.instance.recoverTwoFactor(context, widget.sessionID);
|
UserService.instance.recoverTwoFactor(
|
||||||
|
context,
|
||||||
|
widget.sessionID,
|
||||||
|
TwoFactorType.totp,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:ui';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import "package:photos/generated/l10n.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/services/user_service.dart';
|
||||||
import 'package:photos/utils/dialog_util.dart';
|
import 'package:photos/utils/dialog_util.dart';
|
||||||
|
|
||||||
@ -9,8 +10,10 @@ class TwoFactorRecoveryPage extends StatefulWidget {
|
|||||||
final String sessionID;
|
final String sessionID;
|
||||||
final String encryptedSecret;
|
final String encryptedSecret;
|
||||||
final String secretDecryptionNonce;
|
final String secretDecryptionNonce;
|
||||||
|
final TwoFactorType type;
|
||||||
|
|
||||||
const TwoFactorRecoveryPage(
|
const TwoFactorRecoveryPage(
|
||||||
|
this.type,
|
||||||
this.sessionID,
|
this.sessionID,
|
||||||
this.encryptedSecret,
|
this.encryptedSecret,
|
||||||
this.secretDecryptionNonce, {
|
this.secretDecryptionNonce, {
|
||||||
@ -71,6 +74,7 @@ class _TwoFactorRecoveryPageState extends State<TwoFactorRecoveryPage> {
|
|||||||
? () async {
|
? () async {
|
||||||
await UserService.instance.removeTwoFactor(
|
await UserService.instance.removeTwoFactor(
|
||||||
context,
|
context,
|
||||||
|
widget.type,
|
||||||
widget.sessionID,
|
widget.sessionID,
|
||||||
_recoveryKey.text,
|
_recoveryKey.text,
|
||||||
widget.encryptedSecret,
|
widget.encryptedSecret,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user