Skip to content

Commit

Permalink
NEW Give feedback of password strength
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Oct 4, 2024
1 parent 547afc6 commit be47fa3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/js/vendor.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions client/src/legacy/ConfirmedPasswordField.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import $ from 'jquery';
import debounce from 'lodash/debounce';

$(document).on('click', '.confirmedpassword .showOnClick a', function () {
var $container = $('.showOnClickContainer', $(this).parent());
Expand All @@ -12,3 +13,25 @@ $(document).on('click', '.confirmedpassword .showOnClick a', function () {

return false;
});

$(document).on('input', '.confirmedpassword .password', function() {
const $password = $(this);
debounce(function () {
const url = $password.attr('data-strengthurl');
const $container = $password.closest('.confirmedpassword');
const $strength = $container.find('.passwordstrength');
if (!$strength.length || !url) {
return;
}
$.post({
url,
data: JSON.stringify({
password: $password.val()
}),
}).done(function(data) {
const json = JSON.parse(data);
const level = json.valid ? 'success' : 'danger';
$strength.html('<p class="alert alert-' + level + '" role="alert">' + json.message + '</p>');
});
}, 300)()
});

0 comments on commit be47fa3

Please sign in to comment.