Files
zulip/zephyr/static/js/common.js
Keegan McAllister 07bb220194 Add a password strength check on the signup page
(imported from commit a44101485e49fd7a7951bda05ba10a021b6d3ee0)
2013-04-10 18:05:00 -04:00

29 lines
871 B
JavaScript

var status_classes = 'alert-error alert-success alert-info';
function autofocus(selector) {
$(function () {
$(selector)[0].focus();
});
}
// Return a list of
//
// - A width setting for a graphical password quality indicator.
// - A boolean indicating whether the password is acceptable.
//
// Assumes that zxcvbn.js has been loaded.
//
// This is in common.js because we want to use it from the signup page
// and also from the in-app password change interface.
function password_quality(password) {
var result = zxcvbn(password);
var quality = Math.min(1, Math.log(1 + result.crack_time) / 22);
// Display the password quality score on a progress bar
// which bottoms out at 10% so there's always something
// for the user to see.
var width = ((90 * quality) + 10) + '%';
return [width, result.crack_time >= 1e5];
}