Skip to content

armgit / ente

Public Imported from GitHub
0

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

Guard passkey async contexts

Neeraj Gupta8aacbb3af314
diff --git a/mobile/apps/photos/lib/ui/account/passkey_page.dart b/mobile/apps/photos/lib/ui/account/passkey_page.dart
index 8518fbdf07..7e404563a0 100644
--- a/mobile/apps/photos/lib/ui/account/passkey_page.dart
+++ b/mobile/apps/photos/lib/ui/account/passkey_page.dart
@@ -93,11 +93,11 @@ class _PasskeyPageState extends State<PasskeyPage> {
}
Future<void> _handleDeeplink(Uri? uri) async {
- if (!context.mounted ||
+ if (!mounted ||
Configuration.instance.hasConfiguredAccount() ||
uri == null) {
_logger.warning(
- 'ignored deeplink: contextMounted ${context.mounted} hasConfiguredAccount ${Configuration.instance.hasConfiguredAccount()}',
+ 'ignored deeplink: mounted $mounted hasConfiguredAccount ${Configuration.instance.hasConfiguredAccount()}',
);
return;
}
diff --git a/mobile/apps/photos/lib/ui/settings/security/security_settings_page.dart b/mobile/apps/photos/lib/ui/settings/security/security_settings_page.dart
index 35b62934cd..7bb10312cc 100644
--- a/mobile/apps/photos/lib/ui/settings/security/security_settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings/security/security_settings_page.dart
@@ -230,8 +230,7 @@ class _SecuritySettingsPageState extends State<SecuritySettingsPage> {
context,
AppLocalizations.of(context).authToViewPasskey,
);
- if (hasAuthenticated) {
- if (!context.mounted) return;
+ if (hasAuthenticated && mounted && context.mounted) {
await _handlePasskeyClick(context);
}
}
@@ -240,10 +239,10 @@ class _SecuritySettingsPageState extends State<SecuritySettingsPage> {
try {
final isPassKeyResetEnabled = await PasskeyService.instance
.isPasskeyRecoveryEnabled();
+ if (!mounted || !buildContext.mounted) return;
if (!isPassKeyResetEnabled) {
- if (!mounted) return;
final Uint8List recoveryKey = await UserService.instance
- .getOrCreateRecoveryKey(context);
+ .getOrCreateRecoveryKey(buildContext);
final resetKey = CryptoUtil.generateKey();
final resetKeyBase64 = CryptoUtil.bin2base64(resetKey);
final encryptionResult = CryptoUtil.encryptSync(resetKey, recoveryKey);
@@ -253,12 +252,13 @@ class _SecuritySettingsPageState extends State<SecuritySettingsPage> {
CryptoUtil.bin2base64(encryptionResult.nonce!),
);
}
- if (!buildContext.mounted) return;
+ if (!mounted || !buildContext.mounted) return;
PasskeyService.instance.openPasskeyPage(buildContext).ignore();
} catch (e, s) {
_logger.severe("failed to open passkey page", e, s);
- if (!mounted) return;
- await showGenericErrorDialog(context: context, error: e);
+ if (buildContext.mounted) {
+ await showGenericErrorDialog(context: buildContext, error: e);
+ }
}
}