[Web] use saved password policy for pwgen

This commit is contained in:
FreddleSpl0it 2023-01-06 13:18:59 +01:00
parent 606eaad8f7
commit c928948b15
2 changed files with 19 additions and 2 deletions

View File

@ -12,14 +12,22 @@ $(document).ready(function() {
$.notify({message: msg},{z_index: 20000, delay: auto_hide, type: type,placement: {from: "bottom",align: "right"},animate: {enter: 'animated fadeInUp',exit: 'animated fadeOutDown'}});
}
$(".generate_password").click(function( event ) {
$(".generate_password").click(async function( event ) {
try {
var password_policy = await window.fetch("/api/v1/get/passwordpolicy", { method:'GET', cache:'no-cache' });
var password_policy = await password_policy.json();
random_passwd_length = password_policy.length;
} catch(err) {
var random_passwd_length = 8;
}
event.preventDefault();
$('[data-hibp]').trigger('input');
if (typeof($(this).closest("form").data('pwgen-length')) == "number") {
var random_passwd = GPW.pronounceable($(this).closest("form").data('pwgen-length'))
}
else {
var random_passwd = GPW.pronounceable(8)
var random_passwd = GPW.pronounceable(random_passwd_length)
}
$(this).closest("form").find('[data-pwgen-field]').attr('type', 'text');
$(this).closest("form").find('[data-pwgen-field]').val(random_passwd);

View File

@ -561,6 +561,15 @@ if (isset($_GET['query'])) {
echo '{}';
}
break;
default:
$password_complexity_rules = password_complexity('get');
if ($password_complexity_rules !== false) {
process_get_return($password_complexity_rules);
}
else {
echo '{}';
}
break;
}
break;