Selaa lähdekoodia

add "Action Required" prompt

when encountering http status 449 during vault unlock. fixes #3181

Co-authored-by: SailReal <julian.raufelder@skymatic.de>
(cherry picked from commit f2e7d0fae285c107350cdc219008c5085a79b523)
Sebastian Stenzel 1 vuosi sitten
vanhempi
commit
d29872e69e

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

@@ -25,6 +25,7 @@ public enum FxmlFile {
 	HUB_REGISTER_FAILED("/fxml/hub_register_failed.fxml"), //
 	HUB_SETUP_DEVICE("/fxml/hub_setup_device.fxml"), //
 	HUB_UNAUTHORIZED_DEVICE("/fxml/hub_unauthorized_device.fxml"), //
+	HUB_REQUIRE_ACCOUNT_INIT("/fxml/hub_require_account_init.fxml"), //
 	LOCK_FORCED("/fxml/lock_forced.fxml"), //
 	LOCK_FAILED("/fxml/lock_failed.fxml"), //
 	MAIN_WINDOW("/fxml/main_window.fxml"), //

+ 1 - 0
src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java

@@ -53,6 +53,7 @@ public enum FontAwesome5Icon {
 	TIMES("\uF00D"), //
 	TRASH("\uF1F8"), //
 	UNLINK("\uf127"), //
+	USER_COG("\uf4fe"), //
 	WRENCH("\uF0AD"), //
 	WINDOW_MINIMIZE("\uF2D1"), //
 	;

+ 8 - 3
src/main/java/org/cryptomator/ui/keyloading/hub/HubConfig.java

@@ -21,11 +21,16 @@ public class HubConfig {
 
 	public URI getApiBaseUrl() {
 		if (apiBaseUrl != null) {
-			return URI.create(apiBaseUrl);
-		} else {
-			// legacy approach
+			// make sure to end on "/":
+			return URI.create(apiBaseUrl + "/").normalize();
+		} else { // legacy approach
 			assert devicesResourceUrl != null;
+			// make sure to end on "/":
 			return URI.create(devicesResourceUrl + "/..").normalize();
 		}
 	}
+
+	public URI getWebappBaseUrl() {
+		return getApiBaseUrl().resolve("../app/");
+	}
 }

+ 13 - 0
src/main/java/org/cryptomator/ui/keyloading/hub/HubKeyLoadingModule.java

@@ -119,6 +119,7 @@ public abstract class HubKeyLoadingModule {
 		return fxmlLoaders.createScene(FxmlFile.HUB_LEGACY_REGISTER_DEVICE);
 	}
 
+
 	@Provides
 	@FxmlScene(FxmlFile.HUB_REGISTER_SUCCESS)
 	@KeyLoadingScoped
@@ -147,6 +148,13 @@ public abstract class HubKeyLoadingModule {
 		return fxmlLoaders.createScene(FxmlFile.HUB_UNAUTHORIZED_DEVICE);
 	}
 
+	@Provides
+	@FxmlScene(FxmlFile.HUB_REQUIRE_ACCOUNT_INIT)
+	@KeyLoadingScoped
+	static Scene provideRequireAccountInitScene(@KeyLoading FxmlLoaderFactory fxmlLoaders) {
+		return fxmlLoaders.createScene(FxmlFile.HUB_REQUIRE_ACCOUNT_INIT);
+	}
+
 	@Binds
 	@IntoMap
 	@FxControllerKey(NoKeychainController.class)
@@ -191,4 +199,9 @@ public abstract class HubKeyLoadingModule {
 	@IntoMap
 	@FxControllerKey(UnauthorizedDeviceController.class)
 	abstract FxController bindUnauthorizedDeviceController(UnauthorizedDeviceController controller);
+
+	@Binds
+	@IntoMap
+	@FxControllerKey(RequireAccountInitController.class)
+	abstract FxController bindRequireAccountInitController(RequireAccountInitController controller);
 }

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 8 - 1
src/main/java/org/cryptomator/ui/keyloading/hub/ReceiveKeyController.java


+ 46 - 0
src/main/java/org/cryptomator/ui/keyloading/hub/RequireAccountInitController.java

@@ -0,0 +1,46 @@
+package org.cryptomator.ui.keyloading.hub;
+
+import org.cryptomator.ui.common.FxController;
+import org.cryptomator.ui.keyloading.KeyLoading;
+import org.cryptomator.ui.keyloading.KeyLoadingScoped;
+
+import javax.inject.Inject;
+import javafx.application.Application;
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.stage.Stage;
+import javafx.stage.WindowEvent;
+import java.util.concurrent.CompletableFuture;
+
+@KeyLoadingScoped
+public class RequireAccountInitController implements FxController {
+
+	private final Application application;
+	private final HubConfig hubConfig;
+	private final Stage window;
+	private final CompletableFuture<ReceivedKey> result;
+
+	@Inject
+	public RequireAccountInitController(Application application, HubConfig hubConfig, @KeyLoading Stage window, CompletableFuture<ReceivedKey> result) {
+		this.application = application;
+		this.hubConfig = hubConfig;
+		this.window = window;
+		this.result = result;
+		this.window.addEventHandler(WindowEvent.WINDOW_HIDING, this::windowClosed);
+	}
+
+	@FXML
+	public void completeSetup() {
+		application.getHostServices().showDocument(hubConfig.getWebappBaseUrl().resolve("profile").toString());
+		close();
+	}
+
+	@FXML
+	public void close() {
+		window.close();
+	}
+
+	private void windowClosed(WindowEvent windowEvent) {
+		result.cancel(true);
+	}
+}

+ 60 - 0
src/main/resources/fxml/hub_require_account_init.fxml

@@ -0,0 +1,60 @@
+<?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.Group?>
+<?import javafx.scene.layout.HBox?>
+<?import javafx.scene.layout.Region?>
+<?import javafx.scene.layout.StackPane?>
+<?import javafx.scene.layout.VBox?>
+<?import javafx.scene.shape.Circle?>
+<?import javafx.scene.text.TextFlow?>
+<?import javafx.scene.text.Text?>
+<?import javafx.scene.control.Hyperlink?>
+<HBox xmlns:fx="http://javafx.com/fxml"
+	  xmlns="http://javafx.com/javafx"
+	  fx:controller="org.cryptomator.ui.keyloading.hub.RequireAccountInitController"
+	  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="USER_COG" glyphSize="24"/>
+			</StackPane>
+		</Group>
+		<VBox HBox.hgrow="ALWAYS">
+			<Label styleClass="label-large" text="%hub.requireAccountInit.message" wrapText="true" textAlignment="LEFT">
+				<padding>
+					<Insets bottom="6" top="6"/>
+				</padding>
+			</Label>
+
+			<TextFlow styleClass="text-flow">
+				<Text text="%hub.requireAccountInit.description.0"/>
+				<Text text=" "/>
+				<Hyperlink styleClass="hyperlink-underline" text="%hub.requireAccountInit.description.1" onAction="#completeSetup"/>
+				<Text text="%hub.requireAccountInit.description.2"/>
+			</TextFlow>
+
+			<Region VBox.vgrow="ALWAYS" minHeight="18"/>
+			<ButtonBar buttonMinWidth="120" buttonOrder="+C">
+				<buttons>
+					<Button text="%generic.button.close" ButtonBar.buttonData="CANCEL_CLOSE" defaultButton="true" onAction="#close"/>
+				</buttons>
+			</ButtonBar>
+		</VBox>
+	</children>
+</HBox>

+ 5 - 0
src/main/resources/i18n/strings.properties

@@ -170,6 +170,11 @@ hub.registerFailed.description=An error was thrown in the naming process. For mo
 ### Unauthorized
 hub.unauthorized.message=Access denied
 hub.unauthorized.description=Your device has not yet been authorized to access this vault. Ask the vault owner to authorize it.
+### Requires Account Initialization
+hub.requireAccountInit.message=Action required
+hub.requireAccountInit.description.0=To proceed, please complete the steps required
+hub.requireAccountInit.description.1=in your Hub User Profile
+hub.requireAccountInit.description.2=.
 ### License Exceeded
 hub.invalidLicense.message=Hub License invalid
 hub.invalidLicense.description=Your Cryptomator Hub instance has an invalid license. Please inform a Hub administrator to upgrade or renew the license.