Browse Source

Merge pull request #2325 from cryptomator/feature/recoverykey-success-notification

implemented recoverykey reset password success notification screen
mindmonk 2 years ago
parent
commit
153ccef8a2

+ 1 - 0
src/main/java/org/cryptomator/ui/common/FxmlFile.java

@@ -27,6 +27,7 @@ public enum FxmlFile {
 	RECOVERYKEY_CREATE("/fxml/recoverykey_create.fxml"), //
 	RECOVERYKEY_RECOVER("/fxml/recoverykey_recover.fxml"), //
 	RECOVERYKEY_RESET_PASSWORD("/fxml/recoverykey_reset_password.fxml"), //
+	RECOVERYKEY_RESET_PASSWORD_SUCCESS("/fxml/recoverykey_reset_password_success.fxml"), //
 	RECOVERYKEY_SUCCESS("/fxml/recoverykey_success.fxml"), //
 	REMOVE_VAULT("/fxml/remove_vault.fxml"), //
 	UNLOCK_ENTER_PASSWORD("/fxml/unlock_enter_password.fxml"),

+ 13 - 0
src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyModule.java

@@ -98,6 +98,14 @@ abstract class RecoveryKeyModule {
 		return fxmlLoaders.createScene(FxmlFile.RECOVERYKEY_RESET_PASSWORD);
 	}
 
+	@Provides
+	@FxmlScene(FxmlFile.RECOVERYKEY_RESET_PASSWORD_SUCCESS)
+	@RecoveryKeyScoped
+	static Scene provideRecoveryKeyResetPasswordSuccessScene(@RecoveryKeyWindow FxmlLoaderFactory fxmlLoaders) {
+		return fxmlLoaders.createScene(FxmlFile.RECOVERYKEY_RESET_PASSWORD_SUCCESS);
+	}
+
+
 	// ------------------
 
 	@Binds
@@ -127,6 +135,11 @@ abstract class RecoveryKeyModule {
 	@FxControllerKey(RecoveryKeyResetPasswordController.class)
 	abstract FxController bindRecoveryKeyResetPasswordController(RecoveryKeyResetPasswordController controller);
 
+	@Binds
+	@IntoMap
+	@FxControllerKey(RecoveryKeyResetPasswordSuccessController.class)
+	abstract FxController bindRecoveryKeyResetPasswordSuccessController(RecoveryKeyResetPasswordSuccessController controller);
+
 	@Provides
 	@IntoMap
 	@FxControllerKey(NewPasswordController.class)

+ 6 - 5
src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordController.java

@@ -31,24 +31,26 @@ public class RecoveryKeyResetPasswordController implements FxController {
 	private final ExecutorService executor;
 	private final StringProperty recoveryKey;
 	private final Lazy<Scene> recoverScene;
+	private final Lazy<Scene> recoverResetPasswordSuccessScene;
 	private final FxApplicationWindows appWindows;
 
 	public NewPasswordController newPasswordController;
 
 	@Inject
-	public RecoveryKeyResetPasswordController(@RecoveryKeyWindow Stage window, @RecoveryKeyWindow Vault vault, RecoveryKeyFactory recoveryKeyFactory, ExecutorService executor, @RecoveryKeyWindow StringProperty recoveryKey, @FxmlScene(FxmlFile.RECOVERYKEY_RECOVER) Lazy<Scene> recoverScene, FxApplicationWindows appWindows) {
+	public RecoveryKeyResetPasswordController(@RecoveryKeyWindow Stage window, @RecoveryKeyWindow Vault vault, RecoveryKeyFactory recoveryKeyFactory, ExecutorService executor, @RecoveryKeyWindow StringProperty recoveryKey, @FxmlScene(FxmlFile.RECOVERYKEY_RECOVER) Lazy<Scene> recoverScene, @FxmlScene(FxmlFile.RECOVERYKEY_RESET_PASSWORD_SUCCESS) Lazy<Scene> recoverResetPasswordSuccessScene, FxApplicationWindows appWindows) {
 		this.window = window;
 		this.vault = vault;
 		this.recoveryKeyFactory = recoveryKeyFactory;
 		this.executor = executor;
 		this.recoveryKey = recoveryKey;
 		this.recoverScene = recoverScene;
+		this.recoverResetPasswordSuccessScene = recoverResetPasswordSuccessScene;
 		this.appWindows = appWindows;
 	}
 
 	@FXML
-	public void back() {
-		window.setScene(recoverScene.get());
+	public void close() {
+		window.close();
 	}
 
 	@FXML
@@ -59,8 +61,7 @@ public class RecoveryKeyResetPasswordController implements FxController {
 		});
 		task.setOnSucceeded(event -> {
 			LOG.info("Used recovery key to reset password for {}.", vault.getDisplayablePath());
-			// TODO show success screen
-			window.close();
+			window.setScene(recoverResetPasswordSuccessScene.get());
 		});
 		task.setOnFailed(event -> {
 			LOG.error("Resetting password failed.", task.getException());

+ 24 - 0
src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyResetPasswordSuccessController.java

@@ -0,0 +1,24 @@
+package org.cryptomator.ui.recoverykey;
+
+import org.cryptomator.ui.common.FxController;
+
+import javax.inject.Inject;
+import javafx.fxml.FXML;
+import javafx.stage.Stage;
+
+@RecoveryKeyScoped
+public class RecoveryKeyResetPasswordSuccessController  implements FxController {
+
+	private final Stage window;
+
+	@Inject
+	public RecoveryKeyResetPasswordSuccessController(@RecoveryKeyWindow Stage window) {
+		this.window = window;
+	}
+
+	@FXML
+	public void close() {
+		window.close();
+	}
+
+}

+ 1 - 1
src/main/resources/fxml/recoverykey_recover.fxml

@@ -35,7 +35,7 @@
 		<Region VBox.vgrow="ALWAYS"/>
 
 		<VBox alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS">
-			<ButtonBar buttonMinWidth="120" buttonOrder="C+X">
+			<ButtonBar buttonMinWidth="120" buttonOrder="+CX">
 				<buttons>
 					<Button text="%generic.button.cancel" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#close"/>
 					<Button text="%generic.button.next" ButtonBar.buttonData="NEXT_FORWARD" defaultButton="true" onAction="#recover" disable="${!controller.validRecoveryKey}"/>

+ 3 - 3
src/main/resources/fxml/recoverykey_reset_password.fxml

@@ -22,10 +22,10 @@
 		<Region VBox.vgrow="ALWAYS"/>
 
 		<VBox alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS">
-			<ButtonBar buttonMinWidth="120" buttonOrder="B+I">
+			<ButtonBar buttonMinWidth="120" buttonOrder="+CI">
 				<buttons>
-					<Button text="%generic.button.back" ButtonBar.buttonData="BACK_PREVIOUS" cancelButton="true" onAction="#back"/>
-					<Button text="%generic.button.done" ButtonBar.buttonData="FINISH" defaultButton="true" onAction="#done" disable="${!controller.validPassword}"/>
+					<Button text="%generic.button.cancel" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#close"/>
+					<Button text="%generic.button.reset" ButtonBar.buttonData="FINISH" defaultButton="true" onAction="#done" disable="${!controller.validPassword}"/>
 				</buttons>
 			</ButtonBar>
 		</VBox>

+ 53 - 0
src/main/resources/fxml/recoverykey_reset_password_success.fxml

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<?import org.cryptomator.ui.controls.FontAwesome5IconView?>
+<?import javafx.geometry.Insets?>
+<?import javafx.scene.control.Button?>
+<?import javafx.scene.control.ButtonBar?>
+<?import javafx.scene.control.Label?>
+<?import javafx.scene.layout.HBox?>
+<?import javafx.scene.layout.StackPane?>
+<?import javafx.scene.layout.VBox?>
+<?import javafx.scene.shape.Circle?>
+<?import javafx.scene.Group?>
+<?import javafx.scene.layout.Region?>
+<HBox xmlns:fx="http://javafx.com/fxml"
+	  xmlns="http://javafx.com/javafx"
+	  fx:controller="org.cryptomator.ui.recoverykey.RecoveryKeyResetPasswordSuccessController"
+	  minWidth="400"
+	  maxWidth="400"
+	  minHeight="145"
+	  spacing="12"
+	  alignment="TOP_LEFT">
+<padding>
+	<Insets topRightBottomLeft="12"/>
+</padding>
+<children>
+	<Group>
+		<StackPane>
+			<padding>
+				<Insets topRightBottomLeft="6"/>
+			</padding>
+			<Circle styleClass="glyph-icon-primary" radius="24"/>
+			<FontAwesome5IconView styleClass="glyph-icon-white" glyph="CHECK" glyphSize="24"/>
+		</StackPane>
+	</Group>
+
+	<VBox HBox.hgrow="ALWAYS">
+		<Label styleClass="label-large" text="%recoveryKey.recover.resetSuccess.message" wrapText="true" textAlignment="LEFT">
+			<padding>
+				<Insets bottom="6" top="6"/>
+			</padding>
+		</Label>
+
+		<Label text="%recoveryKey.recover.resetSuccess.description" wrapText="true" textAlignment="LEFT"/>
+
+		<Region VBox.vgrow="ALWAYS" minHeight="18"/>
+		<ButtonBar buttonMinWidth="120" buttonOrder="+C">
+			<buttons>
+				<Button text="%generic.button.close" ButtonBar.buttonData="CANCEL_CLOSE" defaultButton="true" cancelButton="true" onAction="#close"/>
+			</buttons>
+		</ButtonBar>
+	</VBox>
+</children>
+</HBox>

+ 1 - 1
src/main/resources/fxml/recoverykey_success.fxml

@@ -24,7 +24,7 @@
 		<VBox alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS">
 			<ButtonBar buttonMinWidth="120" buttonOrder="+C">
 				<buttons>
-					<Button text="%generic.button.done" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#close"/>
+					<Button text="%generic.button.close" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#close"/>
 				</buttons>
 			</ButtonBar>
 		</VBox>

+ 7 - 3
src/main/resources/i18n/strings.properties

@@ -14,6 +14,7 @@ generic.button.copied=Copied!
 generic.button.done=Done
 generic.button.next=Next
 generic.button.print=Print
+generic.button.reset=Reset
 
 # Error
 error.message=An error occurred
@@ -360,7 +361,7 @@ vaultOptions.masterkey.changePasswordBtn=Change Password
 vaultOptions.masterkey.forgetSavedPasswordBtn=Forget Saved Password
 vaultOptions.masterkey.recoveryKeyExplanation=A recovery key is your only means to restore access to a vault if you lose your password.
 vaultOptions.masterkey.showRecoveryKeyBtn=Display Recovery Key
-vaultOptions.masterkey.recoverPasswordBtn=Recover Password
+vaultOptions.masterkey.recoverPasswordBtn=Reset Password
 
 
 # Recovery Key
@@ -370,11 +371,14 @@ recoveryKey.create.message=Password required
 recoveryKey.create.description=Enter the password for "%s" to show its recovery key.
 recoveryKey.display.description=The following recovery key can be used to restore access to "%s":
 recoveryKey.display.StorageHints=Keep it somewhere very secure, e.g.:\n • Store it using a password manager\n • Save it on a USB flash drive\n • Print it on paper
-## Recover Vault
-recoveryKey.recover.title=Recover Vault
+## Reset Password
+recoveryKey.recover.title=Reset Password
 recoveryKey.recover.prompt=Enter your recovery key for "%s":
 recoveryKey.recover.validKey=This is a valid recovery key
 recoveryKey.printout.heading=Cryptomator Recovery Key\n"%s"\n
+### Recovery Key Password Reset Success
+recoveryKey.recover.resetSuccess.message=Password reset successful
+recoveryKey.recover.resetSuccess.description=You can unlock your vault with the new password.
 
 # New Password
 newPassword.promptText=Enter a new password