Merge pull request #13928 from paultrudel/make-create-passwords-optional

Make create passwords optional
This commit is contained in:
Richard Alam 2021-12-15 09:39:51 -05:00 committed by GitHub
commit 0a8330a98b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

@ -1,5 +1,7 @@
package org.bigbluebutton.api.model.constraint;
import org.bigbluebutton.api.model.validator.PasswordValidator;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Retention;
@ -8,8 +10,7 @@ import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Size(min = 2, max = 64, message = "Password must be between 8 and 20 characters")
@Constraint(validatedBy = {})
@Constraint(validatedBy = {PasswordValidator.class})
@Target(FIELD)
@Retention(RUNTIME)
public @interface PasswordConstraint {

View File

@ -0,0 +1,21 @@
package org.bigbluebutton.api.model.validator;
import org.bigbluebutton.api.model.constraint.PasswordConstraint;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class PasswordValidator implements ConstraintValidator<PasswordConstraint, String> {
@Override
public void initialize(PasswordConstraint constraintAnnotation) {
ConstraintValidator.super.initialize(constraintAnnotation);
}
@Override
public boolean isValid(String password, ConstraintValidatorContext context) {
if(password == null || password.equals("")) return true;
if(password.length() < 2 || password.length() > 64) return false;
return true;
}
}