diff --git a/main/ui/src/main/java/org/cryptomator/ui/changepassword/ChangePasswordController.java b/main/ui/src/main/java/org/cryptomator/ui/changepassword/ChangePasswordController.java index 1c160c639..ca15a5105 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/changepassword/ChangePasswordController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/changepassword/ChangePasswordController.java @@ -15,6 +15,7 @@ import org.cryptomator.common.vaults.Vault; import org.cryptomator.cryptofs.CryptoFileSystemProvider; import org.cryptomator.cryptolib.api.InvalidPassphraseException; import org.cryptomator.ui.common.Animations; +import org.cryptomator.ui.common.ErrorComponent; import org.cryptomator.ui.common.FxController; import org.cryptomator.ui.controls.FontAwesome5IconView; import org.cryptomator.ui.controls.NiceSecurePasswordField; @@ -38,16 +39,18 @@ public class ChangePasswordController implements FxController { private final Stage window; private final Vault vault; private final ObjectProperty newPassword; + private final ErrorComponent.Builder errorComponent; public NiceSecurePasswordField oldPasswordField; public CheckBox finalConfirmationCheckbox; public Button finishButton; @Inject - public ChangePasswordController(@ChangePasswordWindow Stage window, @ChangePasswordWindow Vault vault, @Named("newPassword") ObjectProperty newPassword) { + public ChangePasswordController(@ChangePasswordWindow Stage window, @ChangePasswordWindow Vault vault, @Named("newPassword") ObjectProperty newPassword, ErrorComponent.Builder errorComponent) { this.window = window; this.vault = vault; this.newPassword = newPassword; + this.errorComponent = errorComponent; } @FXML @@ -69,8 +72,8 @@ public class ChangePasswordController implements FxController { LOG.info("Successful changed password for {}", vault.getDisplayableName()); window.close(); } catch (IOException e) { - // TODO show generic error screen LOG.error("IO error occured during password change. Unable to perform operation.", e); + errorComponent.cause(e).window(window).returnToScene(window.getScene()).build().showErrorScene(); } catch (InvalidPassphraseException e) { Animations.createShakeWindowAnimation(window).play(); oldPasswordField.selectAll(); diff --git a/main/ui/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordController.java b/main/ui/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordController.java index ac21626c5..87d916492 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordController.java @@ -12,6 +12,7 @@ import javafx.stage.Stage; import org.cryptomator.common.vaults.Vault; import org.cryptomator.cryptolib.api.InvalidPassphraseException; import org.cryptomator.ui.common.Animations; +import org.cryptomator.ui.common.ErrorComponent; import org.cryptomator.ui.common.FxController; import org.cryptomator.ui.common.FxmlFile; import org.cryptomator.ui.common.FxmlScene; @@ -36,9 +37,10 @@ public class RecoveryKeyResetPasswordController implements FxController { private final ObjectProperty newPassword; private final Lazy recoverScene; private final BooleanBinding invalidNewPassword; + private final ErrorComponent.Builder errorComponent; @Inject - public RecoveryKeyResetPasswordController(@RecoveryKeyWindow Stage window, @RecoveryKeyWindow Vault vault, RecoveryKeyFactory recoveryKeyFactory, ExecutorService executor, @RecoveryKeyWindow StringProperty recoveryKey, @Named("newPassword")ObjectProperty newPassword, @FxmlScene(FxmlFile.RECOVERYKEY_RECOVER) Lazy recoverScene) { + public RecoveryKeyResetPasswordController(@RecoveryKeyWindow Stage window, @RecoveryKeyWindow Vault vault, RecoveryKeyFactory recoveryKeyFactory, ExecutorService executor, @RecoveryKeyWindow StringProperty recoveryKey, @Named("newPassword")ObjectProperty newPassword, @FxmlScene(FxmlFile.RECOVERYKEY_RECOVER) Lazy recoverScene, ErrorComponent.Builder errorComponent) { this.window = window; this.vault = vault; this.recoveryKeyFactory = recoveryKeyFactory; @@ -47,6 +49,7 @@ public class RecoveryKeyResetPasswordController implements FxController { this.newPassword = newPassword; this.recoverScene = recoverScene; this.invalidNewPassword = Bindings.createBooleanBinding(this::isInvalidNewPassword, newPassword); + this.errorComponent = errorComponent; } @FXML @@ -66,8 +69,8 @@ public class RecoveryKeyResetPasswordController implements FxController { window.close(); }); task.setOnFailed(event -> { - // TODO show generic error screen LOG.error("Resetting password failed.", task.getException()); + errorComponent.cause(task.getException()).window(window).returnToScene(recoverScene.get()).build().showErrorScene(); }); executor.submit(task); }