Skip to content

armgit / ente

Public Imported from GitHub
0

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

add email verification and passkey

AmanRajSinghMourya2bbb26f5026f
diff --git a/mobile/apps/locker/lib/l10n/app_en.arb b/mobile/apps/locker/lib/l10n/app_en.arb
index b96da60cef..ccc3047cb2 100644
--- a/mobile/apps/locker/lib/l10n/app_en.arb
+++ b/mobile/apps/locker/lib/l10n/app_en.arb
@@ -1025,7 +1025,5 @@
"suggestions": "Suggestions",
"noResultsFound": "No results found",
"viewActiveSessions": "View active sessions",
- "authToViewYourActiveSessions": "Please authenticate to view your active sessions",
- "emailVerificationEnableWarning": "To avoid getting locked out of your account, be sure to store a copy of your email 2FA outside of Ente Locker before enabling email verification.",
- "iUnderStand": "I understand"
+ "authToViewYourActiveSessions": "Please authenticate to view your active sessions"
}
diff --git a/mobile/apps/locker/lib/l10n/app_localizations.dart b/mobile/apps/locker/lib/l10n/app_localizations.dart
index 18629f577b..b0feee96b7 100644
--- a/mobile/apps/locker/lib/l10n/app_localizations.dart
+++ b/mobile/apps/locker/lib/l10n/app_localizations.dart
@@ -3011,6 +3011,18 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'No results found'**
String get noResultsFound;
+
+ /// No description provided for @viewActiveSessions.
+ ///
+ /// In en, this message translates to:
+ /// **'View active sessions'**
+ String get viewActiveSessions;
+
+ /// No description provided for @authToViewYourActiveSessions.
+ ///
+ /// In en, this message translates to:
+ /// **'Please authenticate to view your active sessions'**
+ String get authToViewYourActiveSessions;
}
class _AppLocalizationsDelegate
diff --git a/mobile/apps/locker/lib/l10n/app_localizations_en.dart b/mobile/apps/locker/lib/l10n/app_localizations_en.dart
index 7466dde0dd..43e9e8a154 100644
--- a/mobile/apps/locker/lib/l10n/app_localizations_en.dart
+++ b/mobile/apps/locker/lib/l10n/app_localizations_en.dart
@@ -1764,4 +1764,11 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get noResultsFound => 'No results found';
+
+ @override
+ String get viewActiveSessions => 'View active sessions';
+
+ @override
+ String get authToViewYourActiveSessions =>
+ 'Please authenticate to view your active sessions';
}
diff --git a/mobile/apps/locker/lib/ui/settings/pages/security_settings_page.dart b/mobile/apps/locker/lib/ui/settings/pages/security_settings_page.dart
index e489b27fe5..0ee7704419 100644
--- a/mobile/apps/locker/lib/ui/settings/pages/security_settings_page.dart
+++ b/mobile/apps/locker/lib/ui/settings/pages/security_settings_page.dart
@@ -9,8 +9,6 @@ import "package:ente_crypto_api/ente_crypto_api.dart";
import "package:ente_lock_screen/local_authentication_service.dart";
import "package:ente_lock_screen/lock_screen_settings.dart";
import "package:ente_lock_screen/ui/lock_screen_options.dart";
-import "package:ente_ui/components/alert_bottom_sheet.dart";
-import "package:ente_ui/components/buttons/gradient_button.dart";
import "package:ente_ui/components/title_bar_title_widget.dart";
import "package:ente_ui/components/toggle_switch_widget.dart";
import "package:ente_ui/theme/ente_theme.dart";
@@ -70,10 +68,12 @@ class _SecuritySettingsPageState extends State<SecuritySettingsPage> {
const SizedBox(height: 12),
_buildPasskeyItem(context),
const SizedBox(height: 12),
- _buildActiveSessionsItem(context),
- const SizedBox(height: 12),
],
_buildAppLockItem(context),
+ if (_hasLoggedIn) ...[
+ const SizedBox(height: 12),
+ _buildActiveSessionsItem(context),
+ ],
],
),
),
@@ -83,35 +83,29 @@ class _SecuritySettingsPageState extends State<SecuritySettingsPage> {
Widget _buildEmailVerificationItem(BuildContext context) {
final l10n = context.l10n;
- final bool? canDisableMFA = UserService.instance.canDisableEmailMFA();
- if (canDisableMFA == null) {
- // We don't know if the user can disable MFA yet, so we fetch the info
- UserService.instance.getUserDetailsV2().ignore();
- }
return SettingsItem(
title: l10n.emailVerificationToggle,
showChevron: false,
trailing: ToggleSwitchWidget(
value: () => UserService.instance.hasEmailMFAEnabled(),
- onChanged: () async {
- final hasAuthenticated =
- await LocalAuthenticationService.instance.requestLocalAuthentication(
- context,
- l10n.authToChangeEmailVerificationSetting,
- );
- final isEmailMFAEnabled = UserService.instance.hasEmailMFAEnabled();
- if (hasAuthenticated) {
- await _updateEmailMFA(!isEmailMFAEnabled);
- if (mounted) {
- setState(() {});
- }
- }
- },
+ onChanged: () => _onEmailMFAToggle(context),
),
);
}
+ Future<void> _onEmailMFAToggle(BuildContext context) async {
+ final hasAuthenticated =
+ await LocalAuthenticationService.instance.requestLocalAuthentication(
+ context,
+ context.l10n.authToChangeEmailVerificationSetting,
+ );
+ final isEmailMFAEnabled = UserService.instance.hasEmailMFAEnabled();
+ if (hasAuthenticated) {
+ await _updateEmailMFA(!isEmailMFAEnabled);
+ }
+ }
+
Widget _buildPasskeyItem(BuildContext context) {
final l10n = context.l10n;
return SettingsItem(
@@ -215,11 +209,11 @@ class _SecuritySettingsPageState extends State<SecuritySettingsPage> {
}
}
- Future<void> _updateEmailMFA(bool enableEmailMFA) async {
+ Future<void> _updateEmailMFA(bool isEnabled) async {
try {
final UserDetails details =
await UserService.instance.getUserDetailsV2(memoryCount: false);
- if (details.profileData?.canDisableEmailMFA == false) {
+ if ((details.profileData?.canDisableEmailMFA ?? false) == false) {
await Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
@@ -235,30 +229,7 @@ class _SecuritySettingsPageState extends State<SecuritySettingsPage> {
),
);
}
- if (enableEmailMFA) {
- await showAlertBottomSheet(
- context,
- title: context.l10n.warning,
- message: context.l10n.emailVerificationEnableWarning,
- assetPath: "assets/warning-grey.png",
- buttons: [
- GradientButton(
- text: context.l10n.iUnderStand,
- onTap: () async {
- await UserService.instance.updateEmailMFA(enableEmailMFA);
- Navigator.of(context).pop();
- },
- ),
- GradientButton(
- text: context.l10n.cancel,
- buttonType: GradientButtonType.secondary,
- onTap: () => Navigator.of(context).pop(),
- ),
- ],
- );
- } else {
- await UserService.instance.updateEmailMFA(enableEmailMFA);
- }
+ await UserService.instance.updateEmailMFA(isEnabled);
} catch (e) {
showToast(context, context.l10n.somethingWentWrong);
}
diff --git a/mobile/apps/locker/lib/ui/settings/pages/settings_search_page.dart b/mobile/apps/locker/lib/ui/settings/pages/settings_search_page.dart
index d8d5ebd493..bace16202e 100644
--- a/mobile/apps/locker/lib/ui/settings/pages/settings_search_page.dart
+++ b/mobile/apps/locker/lib/ui/settings/pages/settings_search_page.dart
@@ -93,11 +93,26 @@ class _SettingsSearchPageState extends State<SettingsSearchPage> {
category: l10n.security,
page: const SecuritySettingsPage(),
),
+ _SearchableSetting(
+ title: l10n.emailVerificationToggle,
+ category: l10n.security,
+ page: const SecuritySettingsPage(),
+ ),
+ _SearchableSetting(
+ title: l10n.passkey,
+ category: l10n.security,
+ page: const SecuritySettingsPage(),
+ ),
_SearchableSetting(
title: l10n.appLock,
category: l10n.security,
page: const SecuritySettingsPage(),
),
+ _SearchableSetting(
+ title: l10n.viewActiveSessions,
+ category: l10n.security,
+ page: const SecuritySettingsPage(),
+ ),
if (Platform.isAndroid || kDebugMode)
_SearchableSetting(
title: l10n.appearance,