Add token to login credentials and database user
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package envoy.client.ui.controller;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.logging.*;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
@ -56,8 +57,8 @@ public final class LoginScene implements EventListener {
|
||||
|
||||
private boolean registration = false;
|
||||
|
||||
private static final Logger logger = EnvoyLog.getLogger(LoginScene.class);
|
||||
private static final ClientConfig config = ClientConfig.getInstance();
|
||||
private static final Logger logger = EnvoyLog.getLogger(LoginScene.class);
|
||||
private static final ClientConfig config = ClientConfig.getInstance();
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
@ -74,16 +75,20 @@ public final class LoginScene implements EventListener {
|
||||
|
||||
@FXML
|
||||
private void loginButtonPressed() {
|
||||
final String user = userTextField.getText(), pass = passwordField.getText(), repeatPass = repeatPasswordField.getText();
|
||||
|
||||
// Prevent registration with unequal passwords
|
||||
if (registration && !passwordField.getText().equals(repeatPasswordField.getText())) {
|
||||
if (registration && !pass.equals(repeatPass)) {
|
||||
new Alert(AlertType.ERROR, "The entered password is unequal to the repeated one").showAndWait();
|
||||
repeatPasswordField.clear();
|
||||
} else if (!Bounds.isValidContactName(userTextField.getText())) {
|
||||
} else if (!Bounds.isValidContactName(user)) {
|
||||
new Alert(AlertType.ERROR, "The entered user name is not valid (" + Bounds.CONTACT_NAME_PATTERN + ")").showAndWait();
|
||||
userTextField.clear();
|
||||
} else Startup.performHandshake(new LoginCredentials(userTextField.getText(), passwordField.getText(), registration, Startup.VERSION,
|
||||
Startup.loadLastSync(userTextField.getText())));
|
||||
} else {
|
||||
Instant lastSync = Startup.loadLastSync(userTextField.getText());
|
||||
Startup.performHandshake(registration ? LoginCredentials.registration(user, pass, Startup.VERSION, lastSync)
|
||||
: LoginCredentials.login(user, pass, Startup.VERSION, lastSync));
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
Reference in New Issue
Block a user