Commit 159b50f1 authored by o@immerda.ch's avatar o@immerda.ch
Browse files

reintroduce the pwstrength indicator

to fix the issue we had where js would ok and ruby disagrees I
made the meter such that it is never happy below 9 chars and I
updated the zxcv.js library.
parent 3bdb4022
function pwstrength() {
var e = document.getElementById('pwscore');
var ok = document.getElementById('new_ok');
e.innerHTML = ' ';
var p = document.getElementById('new').value;
var s = zxcvbn(p).score;
if (p.length < 9 && s > 2) {
s = 2
}
if (p.length > 0) {
var cols = ['#f00', '#fa0', '#fe0', '#af0', '#0f0'];
var cont = [':\'(', ':(', ':/', ':)', ':D'];
......@@ -13,11 +15,6 @@ function pwstrength() {
e.style.backgroundColor = "white";
e.innerHTML = "&nbsp;";
}
if (s >= 3 && p.length > 9) {
ok.innerHTML = "&#x2714;"
} else {
ok.innerHTML = "&nbsp;"
}
}
function confirmcheck() {
......@@ -32,13 +29,13 @@ function confirmcheck() {
function loadPwstrength() {
if (document.getElementById('confirm')) {
// document.getElementById('new').addEventListener("keyup", pwstrength)
// document.getElementById('new').addEventListener("change", pwstrength)
document.getElementById('new').addEventListener("keyup", pwstrength)
document.getElementById('new').addEventListener("change", pwstrength)
document.getElementById('new').addEventListener("keyup", confirmcheck)
document.getElementById('new').addEventListener("change",confirmcheck)
document.getElementById('confirm').addEventListener("keyup", confirmcheck)
document.getElementById('confirm').addEventListener("change", confirmcheck)
// pwstrength();
pwstrength();
}
}
window.addEventListener("load", loadPwstrength)
<%= javascript_include_tag '/zxcvbn.js' %>
<h3><%= @page_title = t(:change_password) %></h3>
<%= form_tag(password_path, method: "post") do %>
<div class="form-group">
......@@ -6,6 +8,7 @@
</div>
<div class="form-group">
<%= label_tag(:new, (t :new_pw)) %>
<span id="pwscore"></span>
<%= password_field_tag(:new, "", class: "form-control") %>
</div>
<div class="form-group">
......
<div class="col" style="max-width: 600px">
<%= javascript_include_tag '/zxcvbn.js' %>
<div class="row pt-3">
<h3><%= @page_title = t(:new_account) %></h3>
</div>
......@@ -18,6 +19,7 @@
<div class="form-group">
<%= label_tag(:new, (t :new_pw)) %>
<span id="pwscore"></span>
(<a id="pw-help-toggle" href="#" ><%= t(:password_help) %></a>)
<%= password_field_tag(:new, "", value: @new_pw, autofill: 'off', class: "form-control") %>
</div>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment