From d5fa0d17a12c3089b37425a408abd7d8f96d10f3 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Sat, 27 Jun 2020 08:25:37 +0200 Subject: [PATCH] Validate user name during login and registration --- src/main/java/envoy/client/ui/controller/LoginScene.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/envoy/client/ui/controller/LoginScene.java b/src/main/java/envoy/client/ui/controller/LoginScene.java index b17fa81..5c6fab9 100644 --- a/src/main/java/envoy/client/ui/controller/LoginScene.java +++ b/src/main/java/envoy/client/ui/controller/LoginScene.java @@ -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)); }