Merge pull request #13928 from paultrudel/make-create-passwords-optional
Make create passwords optional
This commit is contained in:
commit
0a8330a98b
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user