From 86be1444ea1a045e1d43ba7300c15ed15e202143 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 3 Jan 2024 09:37:50 -0600 Subject: [PATCH] critical desktop password related button/function locks --- .../password/create_password_view.dart | 11 +++++++++++ .../password/desktop_login_view.dart | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/pages_desktop_specific/password/create_password_view.dart b/lib/pages_desktop_specific/password/create_password_view.dart index 2986cd0da..a8c129f90 100644 --- a/lib/pages_desktop_specific/password/create_password_view.dart +++ b/lib/pages_desktop_specific/password/create_password_view.dart @@ -65,7 +65,14 @@ class _CreatePasswordViewState extends ConsumerState { bool get fieldsMatch => passwordController.text == passwordRepeatController.text; + bool _nextLock = false; + void onNextPressed() async { + if (_nextLock) { + return; + } + _nextLock = true; + final String passphrase = passwordController.text; final String repeatPassphrase = passwordRepeatController.text; @@ -75,6 +82,7 @@ class _CreatePasswordViewState extends ConsumerState { message: "A password is required", context: context, )); + _nextLock = false; return; } if (passphrase != repeatPassphrase) { @@ -83,6 +91,7 @@ class _CreatePasswordViewState extends ConsumerState { message: "Password does not match", context: context, )); + _nextLock = false; return; } @@ -106,6 +115,7 @@ class _CreatePasswordViewState extends ConsumerState { message: "Error: $e", context: context, )); + _nextLock = false; return; } @@ -132,6 +142,7 @@ class _CreatePasswordViewState extends ConsumerState { context: context, )); } + _nextLock = false; } @override diff --git a/lib/pages_desktop_specific/password/desktop_login_view.dart b/lib/pages_desktop_specific/password/desktop_login_view.dart index cdd6c8c63..2597704fe 100644 --- a/lib/pages_desktop_specific/password/desktop_login_view.dart +++ b/lib/pages_desktop_specific/password/desktop_login_view.dart @@ -79,11 +79,18 @@ class _DesktopLoginViewState extends ConsumerState { } } + bool _loginLock = false; Future login() async { + if (_loginLock) { + return; + } + _loginLock = true; + try { unawaited( showDialog( context: context, + barrierDismissible: false, builder: (context) => const Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, @@ -138,6 +145,8 @@ class _DesktopLoginViewState extends ConsumerState { context: context, ); } + } finally { + _loginLock = false; } }