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 3, 2024
1 parent 547afc6 commit 4e93b52
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 + ' validation;" role="alert">' + json.message + '</p>');
});
}, 300)()
});

0 comments on commit 4e93b52

Please sign in to comment.