make access password mandatory

This commit is contained in:
Sen 2025-05-26 20:29:08 +02:00
parent 5f49d6c036
commit 435e3f3e29
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
5 changed files with 35 additions and 7 deletions

View file

@ -132,7 +132,9 @@ public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements Button
for(int z = 0; z <= lines.length; z++) {
String line = z == lines.length ? null : lines[z];
if(line == null || (line.startsWith("[") && line.endsWith("]"))) {
if(!name.isEmpty() && !address.isEmpty() && !user.isEmpty() && user.length() < IPlayer.MAX_USER_LENGTH && IPlayer.isValidUser(user) && password.length() < IPlayer.MAX_PASS_LENGTH && access.length() < IPlayer.MAX_PASS_LENGTH && address.length() < 128 && name.length() < 128 && port >= 1024 && port <= 32767)
if(!name.isEmpty() && !address.isEmpty() && !user.isEmpty() && user.length() < IPlayer.MAX_USER_LENGTH && IPlayer.isValidUser(user) &&
password.length() < IPlayer.MAX_PASS_LENGTH && access.length() < IPlayer.MAX_PASS_LENGTH && address.length() < 128 && name.length() < 128 &&
port >= 1024 && port <= 32767 && password.length() >= 8 && access.length() >= 8)
this.elements.add(new ServerInfo(name, address, port, user, password, access, time));
if(line != null) {
address = "";

View file

@ -69,8 +69,8 @@ public class GuiServer extends Gui implements FieldCallback {
this.portLabel = this.add(new Label(404, 0, 76, 20, "Port", true));
this.rangeLabel = this.add(new Label(370, 44, 110, 20, "[1024..32767]", true));
this.userLabel = this.add(new Label(0, 50, 220, 20, "Nutzer", true));
this.passLabel = this.add(new Label(0, 100, 480, 20, "Passwort", true));
this.accLabel = this.add(new Label(0, 150, 480, 20, "Zugang", true));
this.passLabel = this.add(new Label(0, 100, 480, 20, "Passwort (mind. 8 Zeichen)", true));
this.accLabel = this.add(new Label(0, 150, 480, 20, "Zugang (mind. 8 Zeichen)", true));
this.shift();
}
@ -118,7 +118,15 @@ public class GuiServer extends Gui implements FieldCallback {
return;
}
String pass = this.passBox.getText();
if(pass.length() < 8) {
this.passLabel.setText(pass.isEmpty() ? TextColor.RED + "Passwort (mind. 8 Zeichen)" : "Passwort (" + TextColor.RED + "mind. 8 Zeichen" + TextColor.RESET + ")");
return;
}
String acc = this.accBox.getText();
if(acc.length() < 8) {
this.accLabel.setText(acc.isEmpty() ? TextColor.RED + "Zugang (mind. 8 Zeichen)" : "Zugang (" + TextColor.RED + "mind. 8 Zeichen" + TextColor.RESET + ")");
return;
}
if(this.server == null) {
this.lastAddr = addr;
this.lastPort = port;
@ -148,6 +156,10 @@ public class GuiServer extends Gui implements FieldCallback {
}
else if(elem == this.userBox)
this.userLabel.setText("Nutzer");
else if(elem == this.passBox)
this.passLabel.setText("Passwort (mind. 8 Zeichen)");
else if(elem == this.accBox)
this.accLabel.setText("Zugang (mind. 8 Zeichen)");
else if(this.server != null && elem == this.nameBox)
this.nameLabel.setText("Name");
}