Validate user name during login and registration

This commit is contained in:
Kai S. K. Engelbart 2020-06-27 08:25:37 +02:00
parent 5fc341ad53
commit d5fa0d17a1

View File

@ -23,6 +23,7 @@ import envoy.event.EventBus;
import envoy.event.HandshakeRejection;
import envoy.event.MessageStatusChange;
import envoy.exception.EnvoyException;
import envoy.util.Bounds;
import envoy.util.EnvoyLog;
/**
@ -115,8 +116,11 @@ public final class LoginScene {
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(
} else if (!Bounds.isValidContactName(userTextField.getText())) {
new Alert(AlertType.ERROR, "The entered user name is not valid (" + Bounds.CONTACT_NAME_PATTERN.toString() + ")").showAndWait();
userTextField.clear();
} else
performHandshake(
new LoginCredentials(userTextField.getText(), passwordField.getText().toCharArray(), registerCheckBox.isSelected(), Startup.VERSION));
}