critical desktop password related button/function locks

This commit is contained in:
julian 2024-01-03 09:37:50 -06:00
parent ce0b871284
commit 86be1444ea
2 changed files with 20 additions and 0 deletions

View file

@ -65,7 +65,14 @@ class _CreatePasswordViewState extends ConsumerState<CreatePasswordView> {
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<CreatePasswordView> {
message: "A password is required",
context: context,
));
_nextLock = false;
return;
}
if (passphrase != repeatPassphrase) {
@ -83,6 +91,7 @@ class _CreatePasswordViewState extends ConsumerState<CreatePasswordView> {
message: "Password does not match",
context: context,
));
_nextLock = false;
return;
}
@ -106,6 +115,7 @@ class _CreatePasswordViewState extends ConsumerState<CreatePasswordView> {
message: "Error: $e",
context: context,
));
_nextLock = false;
return;
}
@ -132,6 +142,7 @@ class _CreatePasswordViewState extends ConsumerState<CreatePasswordView> {
context: context,
));
}
_nextLock = false;
}
@override

View file

@ -79,11 +79,18 @@ class _DesktopLoginViewState extends ConsumerState<DesktopLoginView> {
}
}
bool _loginLock = false;
Future<void> 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<DesktopLoginView> {
context: context,
);
}
} finally {
_loginLock = false;
}
}