Skip to content

Commit f421836

Browse files
committed
Remove inline JS in change_password.twig template
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 45f3552 commit f421836

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

js/src/server/privileges.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ const CheckAddUser = {
461461
}
462462
};
463463

464+
const selectPasswordRadioWhenChangingPassword = () => {
465+
$('#nopass_0').prop('checked', true);
466+
};
467+
464468
/**
465469
* AJAX scripts for /server/privileges page.
466470
*
@@ -483,6 +487,9 @@ const CheckAddUser = {
483487
window.AJAX.registerTeardown('server/privileges.js', function () {
484488
$('#fieldset_add_user_login').off('change', 'input[name=\'username\']');
485489
$(document).off('click', '#deleteUserCard .btn.ajax');
490+
$('#text_pma_change_pw').off('keyup');
491+
$('#text_pma_change_pw').off('change');
492+
$('#text_pma_change_pw2').off('change');
486493

487494
const editUserGroupModal = document.getElementById('editUserGroupModal');
488495
if (editUserGroupModal) {
@@ -504,6 +511,8 @@ window.AJAX.registerOnload('server/privileges.js', function () {
504511
$('#text_pma_pw').on('keyup', PasswordStrength.handleEvent);
505512
$('#text_pma_pw').on('input', SwitchToUseTextField.handleEvent);
506513
$('#text_pma_change_pw').on('keyup', ChangePasswordStrength.handleEvent);
514+
$('#text_pma_change_pw').on('change', selectPasswordRadioWhenChangingPassword);
515+
$('#text_pma_change_pw2').on('change', selectPasswordRadioWhenChangingPassword);
507516
$(document).on('change', '#select_authentication_plugin', ShowSha256PasswordNotice.handleEvent);
508517
$(document).on('click', '#deleteUserCard .btn.ajax', RevokeUser.handleEvent);
509518

templates/server/privileges/change_password.twig

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,17 @@
1717
</tr>
1818
<tr class="align-middle mb-4">
1919
<td>
20-
<input type="radio" name="nopass" value="0" id="nopass_0" checked="checked">
20+
<input type="radio" name="nopass" value="0" id="nopass_0" checked>
2121
<label for="nopass_0">{% trans 'Password:' %}&nbsp;</label>
2222
</td>
2323
<td>
2424
<div class="row">
2525
<span class="d-flex align-items-center col-4">{% trans 'Enter:' %}</span>
26-
<input type="password" name="pma_pw" id="text_pma_change_pw" size="10" class="textfield col-6"
27-
onkeyup="Functions.checkPasswordStrength($(this).val(), $('#change_password_strength_meter'), meter_obj_label = $('#change_password_strength'), window.CommonParams.get('user'));"
28-
onchange="nopass[1].checked = true">
26+
<input type="password" name="pma_pw" id="text_pma_change_pw" size="10" class="textfield col-6">
2927
</div>
3028
<div class="row mt-2">
3129
<span class="d-flex align-items-center col-4">{% trans 'Re-type:' %}</span>
32-
<input type="password" name="pma_pw2" id="text_pma_change_pw2" size="10" class="textfield col-6" onchange="nopass[1].checked = true">
30+
<input type="password" name="pma_pw2" id="text_pma_change_pw2" size="10" class="textfield col-6">
3331
</div>
3432
</td>
3533
<td class="col-2">

0 commit comments

Comments
 (0)