From 31cb22035b5e91baa19d4e251efa9d32172bb18e Mon Sep 17 00:00:00 2001 From: kske Date: Sat, 19 Sep 2020 09:13:04 +0200 Subject: [PATCH] Add token request to login credentials and "Stay Signed In" checkbox --- .../client/ui/controller/LoginScene.java | 10 ++++-- .../src/main/resources/fxml/LoginScene.fxml | 10 ++++-- .../java/envoy/data/LoginCredentials.java | 31 +++++++++++++------ 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/client/src/main/java/envoy/client/ui/controller/LoginScene.java b/client/src/main/java/envoy/client/ui/controller/LoginScene.java index 71e3988..285f3de 100644 --- a/client/src/main/java/envoy/client/ui/controller/LoginScene.java +++ b/client/src/main/java/envoy/client/ui/controller/LoginScene.java @@ -46,6 +46,9 @@ public final class LoginScene implements EventListener { @FXML private Button loginButton; + @FXML + private CheckBox cbStaySignedIn; + @FXML private Button offlineModeButton; @@ -55,7 +58,7 @@ public final class LoginScene implements EventListener { @FXML private ImageView logo; - private boolean registration = false; + private boolean registration; private static final Logger logger = EnvoyLog.getLogger(LoginScene.class); private static final ClientConfig config = ClientConfig.getInstance(); @@ -76,6 +79,7 @@ public final class LoginScene implements EventListener { @FXML private void loginButtonPressed() { final String user = userTextField.getText(), pass = passwordField.getText(), repeatPass = repeatPasswordField.getText(); + final boolean requestToken = cbStaySignedIn.isSelected(); // Prevent registration with unequal passwords if (registration && !pass.equals(repeatPass)) { @@ -86,8 +90,8 @@ public final class LoginScene implements EventListener { userTextField.clear(); } else { Instant lastSync = Startup.loadLastSync(userTextField.getText()); - Startup.performHandshake(registration ? LoginCredentials.registration(user, pass, Startup.VERSION, lastSync) - : LoginCredentials.login(user, pass, Startup.VERSION, lastSync)); + Startup.performHandshake(registration ? LoginCredentials.registration(user, pass, requestToken, Startup.VERSION, lastSync) + : LoginCredentials.login(user, pass, requestToken, Startup.VERSION, lastSync)); } } diff --git a/client/src/main/resources/fxml/LoginScene.fxml b/client/src/main/resources/fxml/LoginScene.fxml index 1ade0f8..e1316c4 100644 --- a/client/src/main/resources/fxml/LoginScene.fxml +++ b/client/src/main/resources/fxml/LoginScene.fxml @@ -2,6 +2,7 @@ + @@ -32,9 +33,7 @@ -