Hi,
You can create a bean that implements the io.jmix.securityui.password.PasswordValidator
interface. You will probably need to create a separate entity to store password history for users.
import com.company.sample.entity.User;
import io.jmix.securityui.password.PasswordValidationContext;
import io.jmix.securityui.password.PasswordValidationException;
import io.jmix.securityui.password.PasswordValidator;
import org.springframework.stereotype.Component;
@Component
public class MyPasswordValidator implements PasswordValidator<User> {
@Override
public void validate(PasswordValidationContext<User> context) throws PasswordValidationException {
User user = context.getUser();
String password = context.getPassword();
if (password.startsWith("a")) {
throw new PasswordValidationException("Password cannot start with 'a'");
}
}
}