From 6437f74cd355a47b95217d310d34b59af868fe1c Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 13 Oct 2014 17:55:18 +0100 Subject: [PATCH] use req.ip not x-forwarded-for to get ip address for multi currency --- .../Features/Subscription/SubscriptionController.coffee | 4 ++-- .../coffee/Subscription/SubscriptionControllerTests.coffee | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee index 104701fc1b..885e6dcae5 100644 --- a/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee +++ b/services/web/app/coffee/Features/Subscription/SubscriptionController.coffee @@ -22,7 +22,7 @@ module.exports = SubscriptionController = if req.query.v? viewName = "#{viewName}_#{req.query.v}" logger.log viewName:viewName, "showing plans page" - GeoIpLookup.getCurrencyCode req.headers["x-forwarded-for"], (err, recomendedCurrency)-> + GeoIpLookup.getCurrencyCode req.ip, (err, recomendedCurrency)-> res.render viewName, title: "plans_and_pricing" plans: plans @@ -40,7 +40,7 @@ module.exports = SubscriptionController = res.redirect "/user/subscription" else currency = req.query.currency?.toUpperCase() - GeoIpLookup.getCurrencyCode req.headers["x-forwarded-for"], (err, recomendedCurrency)-> + GeoIpLookup.getCurrencyCode req.ip, (err, recomendedCurrency)-> if recomendedCurrency? and !currency? currency = recomendedCurrency RecurlyWrapper.sign { diff --git a/services/web/test/UnitTests/coffee/Subscription/SubscriptionControllerTests.coffee b/services/web/test/UnitTests/coffee/Subscription/SubscriptionControllerTests.coffee index cc57b4ee7a..cb6c5a663b 100644 --- a/services/web/test/UnitTests/coffee/Subscription/SubscriptionControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/Subscription/SubscriptionControllerTests.coffee @@ -81,15 +81,14 @@ describe "SubscriptionController sanboxed", -> describe "plansPage", -> beforeEach (done) -> - @req.headers = - "x-forwarded-for" : "1234.3123.3131.333 313.133.445.666 653.5345.5345.534" + @req.ip = "1234.3123.3131.333 313.133.445.666 653.5345.5345.534" @GeoIpLookup.getCurrencyCode.callsArgWith(1, null, @stubbedCurrencyCode) @res.callback = done @SubscriptionController.plansPage(@req, @res) it "should set the recommended currency from the geoiplookup", (done)-> @res.renderedVariables.recomendedCurrency.should.equal(@stubbedCurrencyCode) - @GeoIpLookup.getCurrencyCode.calledWith(@req.headers["x-forwarded-for"]).should.equal true + @GeoIpLookup.getCurrencyCode.calledWith(@req.ip).should.equal true done() describe "editBillingDetailsPage", ->