Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Give feedback of password strength #1832

Draft
wants to merge 1 commit into
base: 3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)()
});
Loading