From 5f86473e3ec9f8c102da3c555c71feb153706172 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 17 Feb 2023 12:49:38 +0100 Subject: [PATCH] fix recovery key state logic --- .../ui/recoverykey/RecoveryKeyRecoverController.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyRecoverController.java b/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyRecoverController.java index fcc3589db..ab74cd32a 100644 --- a/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyRecoverController.java +++ b/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyRecoverController.java @@ -44,11 +44,12 @@ public class RecoveryKeyRecoverController implements FxController { private final ObservableValue recoveryKeyWrong; private final ObservableValue recoveryKeyInvalid; private final RecoveryKeyFactory recoveryKeyFactory; - private final ObjectProperty recoveryKeyState; private final Lazy resetPasswordScene; private final AutoCompleter autoCompleter; + private volatile boolean isWrongKey; + public TextArea textarea; @Inject @@ -119,8 +120,6 @@ public class RecoveryKeyRecoverController implements FxController { /** * Checks, if vault config is signed with the given key. - *

- * If not, but the deriving recovery key is valid, sets the recoveryKeyState to WRONG. * * @param key byte array of possible signing key * @return true, if vault config is signed with this key @@ -132,7 +131,7 @@ public class RecoveryKeyRecoverController implements FxController { return true; } catch (VaultKeyInvalidException e) { LOG.debug("Provided recovery key does not match vault config signature."); - recoveryKeyState.setValue(RecoveryKeyState.WRONG); + isWrongKey = true; return false; } catch (VaultConfigLoadException e) { LOG.error("Failed to parse vault config", e); @@ -141,10 +140,13 @@ public class RecoveryKeyRecoverController implements FxController { } public void validateRecoveryKey() { + isWrongKey = false; var valid = recoveryKeyFactory.validateRecoveryKey(recoveryKey.get(), unverifiedVaultConfig != null ? this::checkKeyAgainstVaultConfig : null); if (valid) { recoveryKeyState.set(RecoveryKeyState.CORRECT); - } else if (recoveryKeyState.getValue() != RecoveryKeyState.WRONG) { // set via side effect in checkKeyAgainstVaultConfig() + } else if (isWrongKey) { //set via side effect in checkKeyAgainstVaultConfig() + recoveryKeyState.set(RecoveryKeyState.WRONG); + } else { recoveryKeyState.set(RecoveryKeyState.INVALID); } }