Warn when no password are unciphered using a masterkey

Clear masterkey after "See" or "Add" action
This commit is contained in:
Gregory Soutade 2014-02-19 17:34:51 +01:00
parent 6f8f952a92
commit ce1d010b85
2 changed files with 19 additions and 8 deletions

View File

@ -102,8 +102,8 @@ else
} }
} }
echo "</select>\n"; echo "</select>\n";
echo ' <b>Master key </b> <input id="master_key" type="password" onkeypress="if (event.keyCode == 13) update_master_key();"/>'; echo ' <b>Master key </b> <input id="master_key" type="password" onkeypress="if (event.keyCode == 13) update_master_key(true);"/>';
echo "<input type=\"button\" value=\"See\" onclick=\"update_master_key();\" />" . "\n"; echo "<input type=\"button\" value=\"See\" onclick=\"update_master_key(true);\" />" . "\n";
if (!isset($_SERVER['HTTPS'])) if (!isset($_SERVER['HTTPS']))
echo "<div id=\"addon_address\">Current addon address is : http://" . $_SERVER['SERVER_NAME'] . "/" . $user . "</div>\n"; echo "<div id=\"addon_address\">Current addon address is : http://" . $_SERVER['SERVER_NAME'] . "/" . $user . "</div>\n";

View File

@ -219,10 +219,18 @@ function update_stats()
div.appendChild(document.createElement("br")); div.appendChild(document.createElement("br"));
} }
function change_master_key() function change_master_key(warning_unciphered)
{ {
var nb_unciphered = 0;
for(i=0; i<passwords.length; i++) for(i=0; i<passwords.length; i++)
passwords[i].decrypt(current_mkey); {
if (passwords[i].decrypt(current_mkey))
nb_unciphered++;
}
if (!nb_unciphered && warning_unciphered)
alert("No password unciphered with this master key !");
password_div = document.getElementById("passwords"); password_div = document.getElementById("passwords");
password_div.removeAllChilds(); password_div.removeAllChilds();
@ -326,10 +334,13 @@ function change_master_key()
} }
} }
input = document.getElementById("master_key");
input.value = "";
update_stats(); update_stats();
} }
function update_master_key() function update_master_key(warning_unciphered)
{ {
user = select_widget.options[select_widget.selectedIndex].value; user = select_widget.options[select_widget.selectedIndex].value;
@ -352,7 +363,7 @@ function update_master_key()
if (current_mkey != "") if (current_mkey != "")
current_mkey = derive_mkey(current_user, current_mkey); current_mkey = derive_mkey(current_user, current_mkey);
change_master_key(); change_master_key(warning_unciphered);
} }
function start() function start()
@ -361,7 +372,7 @@ function start()
if (select_widget == null) return; if (select_widget == null) return;
return update_master_key(); return update_master_key(false);
} }
function add_password_server(user, pentry) function add_password_server(user, pentry)
@ -505,7 +516,7 @@ function add_password()
passwords.push(pentry); passwords.push(pentry);
change_master_key(); change_master_key(false);
for(i=0; i<inputs.length; i++) for(i=0; i<inputs.length; i++)
{ {