Can we add any listner or is there any document to implement and check Last 5 Password history of User. If the current password user is trying to store and the same password is set previously last 5 times then it must show warning that password cannot be used.
And How to Save every created password in table. Is it possible to create listner to save changed password ?
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'");
}
}
}