Disable emailMFA: request for password if SRP setup is not done
This commit is contained in:
parent
648f68d6a6
commit
31ffb48e0f
2 changed files with 13 additions and 58 deletions
|
@ -3,7 +3,6 @@ import "dart:typed_data";
|
||||||
|
|
||||||
import 'package:ente_auth/core/configuration.dart';
|
import 'package:ente_auth/core/configuration.dart';
|
||||||
import "package:ente_auth/l10n/l10n.dart";
|
import "package:ente_auth/l10n/l10n.dart";
|
||||||
import "package:ente_auth/services/user_service.dart";
|
|
||||||
import "package:ente_auth/theme/ente_theme.dart";
|
import "package:ente_auth/theme/ente_theme.dart";
|
||||||
import 'package:ente_auth/ui/common/dynamic_fab.dart';
|
import 'package:ente_auth/ui/common/dynamic_fab.dart';
|
||||||
import "package:ente_auth/utils/crypto_util.dart";
|
import "package:ente_auth/utils/crypto_util.dart";
|
||||||
|
@ -75,7 +74,7 @@ class _RequestPasswordVerificationPageState
|
||||||
key: const ValueKey("verifyPasswordButton"),
|
key: const ValueKey("verifyPasswordButton"),
|
||||||
isKeypadOpen: isKeypadOpen,
|
isKeypadOpen: isKeypadOpen,
|
||||||
isFormValid: _passwordController.text.isNotEmpty,
|
isFormValid: _passwordController.text.isNotEmpty,
|
||||||
buttonText: context.l10n.logInLabel,
|
buttonText: context.l10n.verifyPassword,
|
||||||
onPressedFunction: () async {
|
onPressedFunction: () async {
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
final dialog = createProgressDialog(context, context.l10n.pleaseWait);
|
final dialog = createProgressDialog(context, context.l10n.pleaseWait);
|
||||||
|
@ -96,6 +95,7 @@ class _RequestPasswordVerificationPageState
|
||||||
dialog.show();
|
dialog.show();
|
||||||
// pop
|
// pop
|
||||||
await widget.onPasswordVerified(keyEncryptionKey);
|
await widget.onPasswordVerified(keyEncryptionKey);
|
||||||
|
dialog.hide();
|
||||||
Navigator.of(context).pop(true);
|
Navigator.of(context).pop(true);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
_logger.severe("Error while verifying password", e, s);
|
_logger.severe("Error while verifying password", e, s);
|
||||||
|
@ -206,62 +206,6 @@ class _RequestPasswordVerificationPageState
|
||||||
thickness: 1,
|
thickness: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
GestureDetector(
|
|
||||||
behavior: HitTestBehavior.opaque,
|
|
||||||
onTap: () async {
|
|
||||||
await UserService.instance.sendOtt(
|
|
||||||
context,
|
|
||||||
email!,
|
|
||||||
isResetPasswordScreen: true,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
context.l10n.forgotPassword,
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.titleMedium!
|
|
||||||
.copyWith(
|
|
||||||
fontSize: 14,
|
|
||||||
decoration: TextDecoration.underline,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
GestureDetector(
|
|
||||||
behavior: HitTestBehavior.opaque,
|
|
||||||
onTap: () async {
|
|
||||||
final dialog = createProgressDialog(
|
|
||||||
context,
|
|
||||||
context.l10n.pleaseWait,
|
|
||||||
);
|
|
||||||
await dialog.show();
|
|
||||||
await Configuration.instance.logout();
|
|
||||||
await dialog.hide();
|
|
||||||
Navigator.of(context)
|
|
||||||
.popUntil((route) => route.isFirst);
|
|
||||||
},
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
context.l10n.changeEmail,
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.titleMedium!
|
|
||||||
.copyWith(
|
|
||||||
fontSize: 14,
|
|
||||||
decoration: TextDecoration.underline,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:ente_auth/core/configuration.dart';
|
import 'package:ente_auth/core/configuration.dart';
|
||||||
import 'package:ente_auth/l10n/l10n.dart';
|
import 'package:ente_auth/l10n/l10n.dart';
|
||||||
|
import 'package:ente_auth/models/user_details.dart';
|
||||||
import 'package:ente_auth/services/local_authentication_service.dart';
|
import 'package:ente_auth/services/local_authentication_service.dart';
|
||||||
import 'package:ente_auth/services/user_service.dart';
|
import 'package:ente_auth/services/user_service.dart';
|
||||||
import 'package:ente_auth/theme/ente_theme.dart';
|
import 'package:ente_auth/theme/ente_theme.dart';
|
||||||
import 'package:ente_auth/ui/account/recovery_key_page.dart';
|
import 'package:ente_auth/ui/account/recovery_key_page.dart';
|
||||||
|
import 'package:ente_auth/ui/account/request_pwd_verification_page.dart';
|
||||||
import 'package:ente_auth/ui/account/sessions_page.dart';
|
import 'package:ente_auth/ui/account/sessions_page.dart';
|
||||||
import 'package:ente_auth/ui/components/captioned_text_widget.dart';
|
import 'package:ente_auth/ui/components/captioned_text_widget.dart';
|
||||||
import 'package:ente_auth/ui/components/expandable_menu_item_widget.dart';
|
import 'package:ente_auth/ui/components/expandable_menu_item_widget.dart';
|
||||||
import 'package:ente_auth/ui/components/menu_item_widget.dart';
|
import 'package:ente_auth/ui/components/menu_item_widget.dart';
|
||||||
import 'package:ente_auth/ui/components/toggle_switch_widget.dart';
|
import 'package:ente_auth/ui/components/toggle_switch_widget.dart';
|
||||||
import 'package:ente_auth/ui/settings/common_settings.dart';
|
import 'package:ente_auth/ui/settings/common_settings.dart';
|
||||||
|
import 'package:ente_auth/utils/crypto_util.dart';
|
||||||
import 'package:ente_auth/utils/dialog_util.dart';
|
import 'package:ente_auth/utils/dialog_util.dart';
|
||||||
import 'package:ente_auth/utils/navigation_util.dart';
|
import 'package:ente_auth/utils/navigation_util.dart';
|
||||||
import 'package:ente_auth/utils/toast_util.dart';
|
import 'package:ente_auth/utils/toast_util.dart';
|
||||||
|
@ -169,6 +173,13 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
|
||||||
|
|
||||||
Future<void> updateEmailMFA(bool isEnabled) async {
|
Future<void> updateEmailMFA(bool isEnabled) async {
|
||||||
try {
|
try {
|
||||||
|
final UserDetails details = await UserService.instance.getUserDetailsV2(memoryCount: false);
|
||||||
|
if(details.profileData?.canDisableEmailMFA == false) {
|
||||||
|
await routeToPage(context, RequestPasswordVerificationPage(onPasswordVerified: (Uint8List keyEncryptionKey) async {
|
||||||
|
final Uint8List loginKey = await CryptoUtil.deriveLoginKey(keyEncryptionKey);
|
||||||
|
await UserService.instance.registerOrUpdateSrp(loginKey);
|
||||||
|
},),);
|
||||||
|
}
|
||||||
await UserService.instance.updateEmailMFA(isEnabled);
|
await UserService.instance.updateEmailMFA(isEnabled);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showToast(context, context.l10n.somethingWentWrongMessage);
|
showToast(context, context.l10n.somethingWentWrongMessage);
|
||||||
|
|
Loading…
Add table
Reference in a new issue