From 3c193bef27cb1481000593a1cee1cd7d9205e995 Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Sat, 2 Nov 2013 18:41:00 +0100 Subject: [PATCH] request remote_addr only when using the comment form --- isso/js/app/api.js | 13 ++++++++----- isso/js/app/isso.js | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/isso/js/app/api.js b/isso/js/app/api.js index 51684a7..d30b346 100644 --- a/isso/js/app/api.js +++ b/isso/js/app/api.js @@ -5,7 +5,7 @@ define(["q"], function(Q) { Q.stopUnhandledRejectionTracking(); Q.longStackSupport = true; - var endpoint = null, remote_addr = null, + var endpoint = null, salt = "Eech7co8Ohloopo9Ol6baimi", location = window.location.pathname; @@ -163,15 +163,18 @@ define(["q"], function(Q) { }); }; - remote_addr = curl("GET", endpoint + "/check-ip", null).then(function(rv) { - return rv.body; - }); + var remote_addr = function() { + return curl("GET", endpoint + "/check-ip", null).then(function(rv) { + return rv.body; + }); + }; return { endpoint: endpoint, - remote_addr: remote_addr, salt: salt, + remote_addr: remote_addr, + create: create, modify: modify, remove: remove, diff --git a/isso/js/app/isso.js b/isso/js/app/isso.js index c61c7ed..a0b06bb 100644 --- a/isso/js/app/isso.js +++ b/isso/js/app/isso.js @@ -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() { if ($(".avatar svg", el).getAttribute("className") === "blank") { $(".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); } 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) { $(".avatar svg", el).replace(lib.identicons.generate(rv, 4, 48)); });