disable password field und unreveal password when vault is processing

This commit is contained in:
Tobias Hagemann
2020-04-21 08:40:12 +02:00
parent 07e5e18d4d
commit 880260d467
3 changed files with 15 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
package org.cryptomator.ui.controls;
import javafx.beans.Observable;
import javafx.beans.binding.Bindings;
import javafx.beans.property.StringProperty;
import javafx.geometry.Pos;
@@ -55,19 +56,24 @@ public class NiceSecurePasswordField extends StackPane {
passwordField.revealPasswordProperty().bind(revealPasswordButton.selectedProperty());
getChildren().addAll(passwordField, iconContainer);
disabledProperty().addListener(this::disabledChanged);
}
private FontAwesome5Icon getRevealPasswordGlyph() {
return revealPasswordButton.isSelected() ? FontAwesome5Icon.EYE_SLASH : FontAwesome5Icon.EYE;
}
private void disabledChanged(@SuppressWarnings("unused") Observable observable) {
revealPasswordButton.setSelected(false);
}
/* Passthrough */
@Override
public void requestFocus() {
passwordField.requestFocus();
}
public String getText() {
return passwordField.getText();
}

View File

@@ -99,6 +99,7 @@ public class MigrationRunController implements FxController {
LOG.info("Migrating vault {}", vault.getPath());
CharSequence password = passwordField.getCharacters();
vault.setState(VaultState.PROCESSING);
passwordField.setDisable(true);
ScheduledFuture<?> progressSyncTask = scheduler.scheduleAtFixedRate(() -> {
Platform.runLater(() -> {
migrationProgress.set(volatileMigrationProgress);
@@ -120,6 +121,7 @@ public class MigrationRunController implements FxController {
}
}).onError(InvalidPassphraseException.class, e -> {
Animations.createShakeWindowAnimation(window).play();
passwordField.setDisable(false);
passwordField.selectAll();
passwordField.requestFocus();
vault.setState(VaultState.NEEDS_MIGRATION);
@@ -133,6 +135,7 @@ public class MigrationRunController implements FxController {
vault.setState(VaultState.NEEDS_MIGRATION);
errorComponent.cause(e).window(window).returnToScene(startScene.get()).build().showErrorScene();
}).andFinally(() -> {
passwordField.setDisable(false);
progressSyncTask.cancel(true);
}).runOnce(executor);
}

View File

@@ -4,7 +4,6 @@ import dagger.Lazy;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.ObjectBinding;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.concurrent.Task;
@@ -30,7 +29,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Named;
import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.NotDirectoryException;
import java.util.Arrays;
@@ -90,9 +88,11 @@ public class UnlockController implements FxController {
public void unlock() {
LOG.trace("UnlockController.unlock()");
CharSequence password = passwordField.getCharacters();
Task<Vault> task = vaultService.createUnlockTask(vault, password);
passwordField.setDisable(true);
task.setOnSucceeded(event -> {
passwordField.setDisable(false);
if (keychainAccess.isPresent() && savePassword.isSelected()) {
try {
keychainAccess.get().storePassphrase(vault.getId(), password);
@@ -105,12 +105,12 @@ public class UnlockController implements FxController {
window.setScene(successScene.get());
});
task.setOnFailed(event -> {
passwordField.setDisable(false);
if (task.getException() instanceof InvalidPassphraseException) {
Animations.createShakeWindowAnimation(window).play();
passwordField.selectAll();
passwordField.requestFocus();
} else if (task.getException() instanceof NotDirectoryException
|| task.getException() instanceof DirectoryNotEmptyException) {
} else if (task.getException() instanceof NotDirectoryException || task.getException() instanceof DirectoryNotEmptyException) {
LOG.error("Unlock failed. Mount point not an empty directory: {}", task.getException().getMessage());
window.setScene(invalidMountPointScene.get());
} else {