diff --git a/data/web/js/build/013-mailcow.js b/data/web/js/build/013-mailcow.js index c734c824..afe17bc6 100644 --- a/data/web/js/build/013-mailcow.js +++ b/data/web/js/build/013-mailcow.js @@ -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); diff --git a/data/web/json_api.php b/data/web/json_api.php index 1823e5a5..acaeaba9 100644 --- a/data/web/json_api.php +++ b/data/web/json_api.php @@ -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;