Skip to content

Commit

Permalink
fix pass issue in cronicle-edge#95
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeTWC1984 committed Apr 3, 2024
1 parent 176f5c5 commit e1acba4
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions htdocs/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,17 +719,36 @@ app.extend({
//if (!window.zxcvbn) load_script('js/external/zxcvbn.js');
},

update_password_strength: function($field, $cont) {
update_password_strength: function ($field, $cont) {
// update password strength indicator after keypress
let score = 0
let crack_time = 'instant'
let password = $field.val()


if (window.zxcvbn) {
var password = $field.val();
var result = zxcvbn( password );
var result = zxcvbn(password);
// Debug.trace("Password score: " + password + ": " + result.score);
var $bar = $cont.find('div.psi_bar');
$bar.removeClass('str0 str1 str2 str3 str4');
if (password.length) $bar.addClass('str' + result.score);
app.last_password_strength = result;
}
else { // basic strength checker
if (password.match(/[a-z]+/)) score += 0.5
if (password.match(/[A-Z]+/)) score += 0.5
if (password.match(/[0-9]+/)) score += 1
if (password.match(/[$@#&!]+/)) score += 1
if (password.length >= 8) {
score += 0.5
crack_time = 'few hours or days'
} else { score -= 0.5}

app.last_password_strength = {
score: score,
crack_time_display: crack_time
}
}
},

get_password_warning: function() {
Expand Down

0 comments on commit e1acba4

Please sign in to comment.