From cde91a77ef1e7b43085398f2e4d59342f7a5ced0 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Thu, 25 Jun 2020 07:49:45 +0200 Subject: [PATCH 1/2] Stop clearing password fields, remove prompt text --- .../envoy/client/ui/controller/LoginScene.java | 15 +++------------ src/main/resources/fxml/LoginScene.fxml | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/main/java/envoy/client/ui/controller/LoginScene.java b/src/main/java/envoy/client/ui/controller/LoginScene.java index 13fc564..2435980 100644 --- a/src/main/java/envoy/client/ui/controller/LoginScene.java +++ b/src/main/java/envoy/client/ui/controller/LoginScene.java @@ -71,9 +71,7 @@ public final class LoginScene { connectionLabel.setText("Server: " + config.getServer() + ":" + config.getPort()); // Show an alert after an unsuccessful handshake - eventBus.register( - HandshakeRejection.class, - e -> Platform.runLater(() -> { clearPasswordFields(); new Alert(AlertType.ERROR, e.get()).showAndWait(); })); + eventBus.register(HandshakeRejection.class, e -> Platform.runLater(() -> { new Alert(AlertType.ERROR, e.get()).showAndWait(); })); } /** @@ -116,10 +114,9 @@ public final class LoginScene { private void loginButtonPressed() { // Prevent registration with unequal passwords - if (registerCheckBox.isSelected() && !passwordField.getText().equals(repeatPasswordField.getText())) { - clearPasswordFields(); + if (registerCheckBox.isSelected() && !passwordField.getText().equals(repeatPasswordField.getText())) new Alert(AlertType.ERROR, "The entered password is unequal to the repeated one").showAndWait(); - } else performHandshake( + else performHandshake( new LoginCredentials(userTextField.getText(), passwordField.getText().toCharArray(), registerCheckBox.isSelected(), Startup.VERSION)); } @@ -134,7 +131,6 @@ public final class LoginScene { // Make repeat password field and label visible / invisible repeatPasswordField.setVisible(registerCheckBox.isSelected()); repeatPasswordLabel.setVisible(registerCheckBox.isSelected()); - clearPasswordFields(); } @FXML @@ -214,9 +210,4 @@ public final class LoginScene { if (receivedMessageCache != null && client.isOnline()) receivedMessageCache.relay(); if (receivedMessageStatusChangeCache != null && client.isOnline()) receivedMessageStatusChangeCache.relay(); } - - private void clearPasswordFields() { - passwordField.clear(); - repeatPasswordField.clear(); - } } diff --git a/src/main/resources/fxml/LoginScene.fxml b/src/main/resources/fxml/LoginScene.fxml index e108008..add7540 100644 --- a/src/main/resources/fxml/LoginScene.fxml +++ b/src/main/resources/fxml/LoginScene.fxml @@ -72,7 +72,7 @@ - + From 4e9702a69141511c6e6a0f59343cb7cb88636737 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Thu, 25 Jun 2020 10:21:27 +0200 Subject: [PATCH 2/2] Clear repeat password field when unequal passwords are entered --- src/main/java/envoy/client/ui/controller/LoginScene.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/envoy/client/ui/controller/LoginScene.java b/src/main/java/envoy/client/ui/controller/LoginScene.java index 2435980..a72ef78 100644 --- a/src/main/java/envoy/client/ui/controller/LoginScene.java +++ b/src/main/java/envoy/client/ui/controller/LoginScene.java @@ -114,8 +114,10 @@ public final class LoginScene { private void loginButtonPressed() { // Prevent registration with unequal passwords - if (registerCheckBox.isSelected() && !passwordField.getText().equals(repeatPasswordField.getText())) + if (registerCheckBox.isSelected() && !passwordField.getText().equals(repeatPasswordField.getText())) { new Alert(AlertType.ERROR, "The entered password is unequal to the repeated one").showAndWait(); + repeatPasswordField.clear(); + } else performHandshake( new LoginCredentials(userTextField.getText(), passwordField.getText().toCharArray(), registerCheckBox.isSelected(), Startup.VERSION)); }