From cfa9fba9cb8c3e83c4b1faa06d59b516ffcb3e67 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 21 Dec 2023 13:45:40 +0100 Subject: [PATCH] SEBSERV-495 fixed minor errors --- .../examconfig/impl/PasswordFieldBuilder.java | 7 +++++++ .../sebserver/gui/widget/PasswordConfirmInput.java | 12 +++++++++++- src/main/resources/messages.properties | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/PasswordFieldBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/PasswordFieldBuilder.java index 0b1134d2..6322ff7d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/PasswordFieldBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/PasswordFieldBuilder.java @@ -124,6 +124,13 @@ public class PasswordFieldBuilder implements InputFieldBuilder { return; } + if (pwd.length() > 255) { + passwordInputField.showError(viewContext + .getI18nSupport() + .getText(new LocTextKey("sebserver.form.validation.fieldError.size.max", 256))); + return; + } + if (!pwd.equals(confirm)) { passwordInputField.showError(viewContext .getI18nSupport() diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/widget/PasswordConfirmInput.java b/src/main/java/ch/ethz/seb/sebserver/gui/widget/PasswordConfirmInput.java index 7369e9f7..e1f4a35e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/widget/PasswordConfirmInput.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/widget/PasswordConfirmInput.java @@ -68,6 +68,9 @@ public class PasswordConfirmInput extends Composite { } public CharSequence getValue() { + if (!checkError()) { + return null; + } final CharSequence value = password.getValue(); if (StringUtils.isNotBlank(value)) { return cryptor.encrypt(value).getOr(value); @@ -91,10 +94,17 @@ public class PasswordConfirmInput extends Composite { final CharSequence pwd = this.password.getValue(); final CharSequence confirm = this.confirm.getValue(); - if (pwd == null && confirm == null) { + if (pwd == null) { return false; } + if (pwd.length() > 255) { + final LocTextKey errmsg = new LocTextKey("sebserver.form.validation.fieldError.size.max", 256); + errorLabel.setText(widgetFactory.getI18nSupport().getText(errmsg)); + errorLabel.setVisible(true); + return true; + } + if (!pwd.equals(confirm)) { errorLabel.setText(widgetFactory.getI18nSupport().getText(VAL_CONFIRM_PWD_TEXT_KEY)); errorLabel.setVisible(true); diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index e74e9d51..41b65184 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -98,6 +98,7 @@ sebserver.form.validation.error.message=There is missing or incorrect form data. sebserver.form.validation.fieldError.size=The size must be between {3} and {4} sebserver.form.validation.fieldError.name=The Name is mandatory and must have a size between {3} and {4} character sebserver.form.validation.fieldError.urlSuffix=The URL Suffix must have a size between {3} and {4} character +sebserver.form.validation.fieldError.size.max=The size must be less than {0} character sebserver.form.validation.fieldError.notNull=This field is mandatory sebserver.form.validation.fieldError.name.notunique=This name is already in use. Please choose another one. sebserver.form.validation.fieldError.username.notunique=This Username is already in use. Please choose another one.