request remote_addr only when using the comment form

This commit is contained in:
Martin Zimmermann 2013-11-02 18:41:00 +01:00
parent 7e73986667
commit 3c193bef27
2 changed files with 10 additions and 7 deletions

View File

@ -5,7 +5,7 @@ define(["q"], function(Q) {
Q.stopUnhandledRejectionTracking(); Q.stopUnhandledRejectionTracking();
Q.longStackSupport = true; Q.longStackSupport = true;
var endpoint = null, remote_addr = null, var endpoint = null,
salt = "Eech7co8Ohloopo9Ol6baimi", salt = "Eech7co8Ohloopo9Ol6baimi",
location = window.location.pathname; location = window.location.pathname;
@ -163,15 +163,18 @@ define(["q"], function(Q) {
}); });
}; };
remote_addr = curl("GET", endpoint + "/check-ip", null).then(function(rv) { var remote_addr = function() {
return rv.body; return curl("GET", endpoint + "/check-ip", null).then(function(rv) {
}); return rv.body;
});
};
return { return {
endpoint: endpoint, endpoint: endpoint,
remote_addr: remote_addr,
salt: salt, salt: salt,
remote_addr: remote_addr,
create: create, create: create,
modify: modify, modify: modify,
remove: remove, remove: remove,

View File

@ -18,7 +18,7 @@ define(["app/text/html", "app/dom", "app/utils", "app/api", "app/markup", "app/i
$(".textarea-wrapper > textarea", el).on("focus", function() { $(".textarea-wrapper > textarea", el).on("focus", function() {
if ($(".avatar svg", el).getAttribute("className") === "blank") { if ($(".avatar svg", el).getAttribute("className") === "blank") {
$(".avatar svg", el).replace( $(".avatar svg", el).replace(
lib.identicons.generate(lib.pbkdf2(api.remote_addr, api.salt, 1000, 6), 4, 48)); lib.identicons.generate(lib.pbkdf2(api.remote_addr(), api.salt, 1000, 6), 4, 48));
} }
}); });
@ -29,7 +29,7 @@ define(["app/text/html", "app/dom", "app/utils", "app/api", "app/markup", "app/i
clearTimeout(active); clearTimeout(active);
} }
active = setTimeout(function() { active = setTimeout(function() {
lib.pbkdf2($(".input-wrapper > [type=email]", el).value || api.remote_addr, api.salt, 1000, 6) lib.pbkdf2($(".input-wrapper > [type=email]", el).value || api.remote_addr(), api.salt, 1000, 6)
.then(function(rv) { .then(function(rv) {
$(".avatar svg", el).replace(lib.identicons.generate(rv, 4, 48)); $(".avatar svg", el).replace(lib.identicons.generate(rv, 4, 48));
}); });