Server side :
* Add $ADMIN_MODE to enable create users * Add protocol version (1 for now) * Give priority to letters in password generator Client side : * Don't still use global variable to get document after loading * Add email type in possible values for username (used by gmail)
This commit is contained in:
@@ -26,8 +26,6 @@ var pkdbf2 = require("pkdbf2").pkdbf2;
|
||||
var aes = require("jsaes").aes;
|
||||
var parseURI = require("parseuri").parseURI;
|
||||
var prefSet = require("simple-prefs");
|
||||
// Global document
|
||||
var doc;
|
||||
var DEBUG = false;
|
||||
|
||||
|
||||
@@ -68,13 +66,13 @@ function on_sumbit()
|
||||
salt = parseURI.parseUri(prefSet.prefs["account_url"]);
|
||||
salt = salt["host"] + salt["path"];
|
||||
|
||||
console.log("salt " + salt);
|
||||
debug("salt " + salt);
|
||||
|
||||
// Get all <input type="text">
|
||||
for (i=0; i<fields.length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
if (field.getAttribute("type") == "text")
|
||||
if (field.getAttribute("type") == "text" || field.getAttribute("type") == "email")
|
||||
{
|
||||
if (field.hasAttribute("name"))
|
||||
my_map.put(field.getAttribute("name"), field.value);
|
||||
@@ -131,31 +129,44 @@ function on_sumbit()
|
||||
gPassRequest.addEventListener("load", function(evt) {
|
||||
r = this.responseText.split("\n");
|
||||
debug("resp " + r);
|
||||
if (r[0] != "<end>" && r[0].startsWith("pass="))
|
||||
{
|
||||
ciphered_password = r[0].split("=");
|
||||
ciphered_password = ciphered_password[1];
|
||||
debug("Ciphered password : " + ciphered_password);
|
||||
clear_password = aes.decryptLongString(hex2a(ciphered_password), aes.init(mkey));
|
||||
aes.finish();
|
||||
// Remove salt
|
||||
clear_password = clear_password.replace(/\0*$/, "");
|
||||
clear_password = clear_password.substr(0, clear_password.length-3);
|
||||
debug("Clear password " + clear_password);
|
||||
field.value = clear_password;
|
||||
}
|
||||
else
|
||||
protocol = r[0].split("=");
|
||||
if (protocol[1] != "1")
|
||||
{
|
||||
debug("No password found");
|
||||
|
||||
ret = false;
|
||||
|
||||
notifications.notify({
|
||||
title: "gPasss",
|
||||
text: "No password found in database",
|
||||
data: "No password found in database",
|
||||
text: "Protocol version not supported, please upgrade your addon",
|
||||
data: "Protocol version not supported, please upgrade your addon",
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (r[1] != "<end>" && r[1].startsWith("pass="))
|
||||
{
|
||||
ciphered_password = r[1].split("=");
|
||||
ciphered_password = ciphered_password[1];
|
||||
debug("Ciphered password : " + ciphered_password);
|
||||
clear_password = aes.decryptLongString(hex2a(ciphered_password), aes.init(mkey));
|
||||
aes.finish();
|
||||
// Remove salt
|
||||
clear_password = clear_password.replace(/\0*$/, "");
|
||||
clear_password = clear_password.substr(0, clear_password.length-3);
|
||||
debug("Clear password " + clear_password);
|
||||
field.value = clear_password;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("No password found");
|
||||
|
||||
ret = false;
|
||||
|
||||
notifications.notify({
|
||||
title: "gPasss",
|
||||
text: "No password found in database",
|
||||
data: "No password found in database",
|
||||
});
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
gPassRequest.addEventListener("error", function(evt) {
|
||||
debug("error");
|
||||
@@ -179,10 +190,11 @@ function on_sumbit()
|
||||
|
||||
function document_loaded(event)
|
||||
{
|
||||
doc = event.target;
|
||||
// If there is a password in the form, add a "submit" listener
|
||||
for(i=0; i<doc.document.forms.length; i++)
|
||||
for(i=0; i<doc.forms.length; i++)
|
||||
{
|
||||
var form = doc.document.forms[i];
|
||||
var form = doc.forms[i];
|
||||
var fields = form.getElementsByTagName("input");
|
||||
for (a=0; a<fields.length; a++)
|
||||
{
|
||||
@@ -202,8 +214,7 @@ var httpRequestObserver =
|
||||
{
|
||||
if (topic == "content-document-global-created")
|
||||
{
|
||||
doc = subject;
|
||||
doc.addEventListener("DOMContentLoaded", document_loaded, false);
|
||||
subject.addEventListener("DOMContentLoaded", document_loaded, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user