diff options
author | Alexander Kabui | 2021-01-29 13:49:05 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-01-31 20:09:00 +0300 |
commit | d6ded9a25f307c86a8fb97c6d7cdf317b391ccc3 (patch) | |
tree | 42308c0c90857edd587b28492bb5cd2e8ad8d6af /wqflask | |
parent | 248779121813bd23603011dc1068447219bbb134 (diff) | |
download | genenetwork2-d6ded9a25f307c86a8fb97c6d7cdf317b391ccc3.tar.gz |
modify check for password strength
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/static/new/javascript/password_strength.js | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/wqflask/wqflask/static/new/javascript/password_strength.js b/wqflask/wqflask/static/new/javascript/password_strength.js index aed7c8d0..59fe8584 100644 --- a/wqflask/wqflask/static/new/javascript/password_strength.js +++ b/wqflask/wqflask/static/new/javascript/password_strength.js @@ -1,4 +1,6 @@ // Generated by CoffeeScript 1.8.0 +// edited by alex date on 28/01/2021 + $(function() { var word_score; $("#password").keyup(function() { @@ -6,33 +8,51 @@ $(function() { passtext = $(this).val(); result = zxcvbn(passtext); if (passtext.length < 6) { - $("#password_strength").html(''); - return $("#password_alert").fadeOut(); + let error_message = `<strong style="color:red;">the password must have a length greater than six characters</strong>` + $("#password_strength").html(error_message); + return $("#password_alert").fadeIn(); } else { word = word_score(result.score); - crack_time = result.crack_time_display; + crack_time = result.crack_times_display.online_throttling_100_per_hour; if (crack_time === "instant") { crack_time = "a second"; } - display = "This is " + word + " password. It can be cracked in " + crack_time + "."; + display = `This is ${word} password.` $("#password_strength").html(display); return $("#password_alert").fadeIn(); } }); return word_score = function(num_score) { - var mapping, result; num_score = parseInt(num_score); console.log("num_score is:", num_score); - mapping = { - 0: "a <strong>terrible</strong>", - 1: "a <strong>bad</strong>", - 2: "a <strong>mediocre</strong>", - 3: "a <strong>good</strong>", - 4: "an <strong>excellent</strong>" - }; - console.log("mapping is:", mapping); - result = mapping[num_score]; - console.log("result is:", result); - return result; + + let passwordFeedback = { + 0:{ + color:"#cc1818", + feedback:"a weak" + }, + + 1:{ + color:"#cc1818", + feedback:"a bad" + }, + + 2:{ + color:"#f59105", + feedback:"a mediocre" + }, + + 3:{ + color:"#44ba34", + feedback:"a strong" + }, + 4:{ + color:"green", + feedback:"a stronger" + } + } + + mappingResult = `<strong style="color:${passwordFeedback[num_score].color};">${passwordFeedback[num_score].feedback}</strong>` + return mappingResult; }; }); |