diff --git a/templates/base_index.html b/templates/base_index.html index 7f08fddfa4b..d84ba1d3bc2 100644 --- a/templates/base_index.html +++ b/templates/base_index.html @@ -1139,7 +1139,7 @@

Multi-cloud applications – beyond PAAS

) { var userCountry = JSON.parse(fetchUserCountry.responseText).country_code; var selectedTakeovers = takeovers.filter(function(item) { - if (item.target_country && item.target_country == userCountry) { + if (item.target_country && item.target_country.toLowerCase() == userCountry.toLowerCase()) { return true; } else if (item.lang === primaryParentLanguage || item.lang === "") { return true; @@ -1185,7 +1185,8 @@

Multi-cloud applications – beyond PAAS

xhr.open("GET", "/takeovers.json", true); xhr.send(); - fetchUserCountry.open("GET", "/user-country.json", true); + const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; + fetchUserCountry.open("GET", `/user-country-tz.json?tz=${timezone}`, true); fetchUserCountry.send(); takeoverAnimation.className += " is-loading"; } diff --git a/webapp/app.py b/webapp/app.py index b7e5516a403..fd0647db9e4 100644 --- a/webapp/app.py +++ b/webapp/app.py @@ -128,7 +128,6 @@ engage_thank_you, french_why_openstack, german_why_openstack, - get_user_country_by_ip, get_user_country_by_tz, json_asset_query, marketo_submit, @@ -630,7 +629,6 @@ def takeovers_index(): core_services_guide.init_app(app) -app.add_url_rule("/user-country.json", view_func=get_user_country_by_ip) app.add_url_rule("/user-country-tz.json", view_func=get_user_country_by_tz) # All other routes diff --git a/webapp/views.py b/webapp/views.py index 2546dfcdf18..6fefde937ff 100644 --- a/webapp/views.py +++ b/webapp/views.py @@ -1052,39 +1052,6 @@ def get_user_country_by_tz(): ) -def get_user_country_by_ip(): - x_forwarded_for = flask.request.headers.get("X-Forwarded-For") - - if x_forwarded_for: - client_ip = x_forwarded_for.split(",")[0] - else: - client_ip = flask.request.remote_addr - - ip_location = ip_reader.get(client_ip) - - try: - country_code = ip_location["country"]["iso_code"] - except KeyError: - # geolite2 can't identify IP address - country_code = None - except Exception as error: - # Errors not documented in the geolite2 module - country_code = None - flask.current_app.extensions["sentry"].captureException( - extra={"ip_location object": ip_location, "error": error} - ) - - response = flask.jsonify( - { - "client_ip": client_ip, - "country_code": country_code, - } - ) - response.cache_control.private = True - - return response - - def subscription_centre(): sfdcLeadId = flask.request.args.get("id") return_url = flask.request.form.get("returnURL")