Recognize "gpass-" before version protocol to avoid (configuration) errors

gPass now blocks login action when the password is not found in database
This commit is contained in:
Grégory Soutadé 2013-11-17 09:31:15 +01:00
parent 637d74b8dd
commit 3e5fa8c638

View File

@ -54,7 +54,7 @@ function debug(s)
console.log(s); console.log(s);
} }
function on_sumbit() function on_sumbit(e)
{ {
var form = this; var form = this;
var fields = form.getElementsByTagName("input"); var fields = form.getElementsByTagName("input");
@ -130,14 +130,25 @@ function on_sumbit()
r = this.responseText.split("\n"); r = this.responseText.split("\n");
debug("resp " + r); debug("resp " + r);
protocol = r[0].split("="); protocol = r[0].split("=");
if (protocol[1] != "1") if ((protocol.length == 2 && protocol[1] != "1" && protocol[1] != "gpass-1") || protocol.length != 2)
{ {
ret = false; ret = false;
notifications.notify({ if (protocol.length == 2 && protocol[1].startsWith("gpass"))
title: "gPasss", {
text: "Protocol version not supported, please upgrade your addon", notifications.notify({
data: "Protocol version not supported, please upgrade your addon", title: "gPasss",
}); text: "Protocol version not supported, please upgrade your addon",
data: "Protocol version not supported, please upgrade your addon",
});
}
else
{
notifications.notify({
title: "gPasss",
text: "Error : It seems that it's not a gPass server",
data: this.responseText,
});
}
} }
else else
{ {
@ -183,7 +194,11 @@ function on_sumbit()
gPassRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); gPassRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
gPassRequest.send(keys); gPassRequest.send(keys);
if (!ret) return ret; if (!ret)
{
e.preventDefault();
return ret;
}
} }
} }
} }