Remove CurrentUser.country.

This was Cloudflare-specific and it was only used for selecting the
currency during user upgrades.
This commit is contained in:
evazion
2022-10-18 18:14:01 -05:00
parent 873c67db58
commit 6a0e553a84
3 changed files with 4 additions and 12 deletions

View File

@@ -5,7 +5,7 @@ class UserUpgradesController < ApplicationController
def create def create
@user_upgrade = authorize UserUpgrade.create(recipient: recipient, purchaser: CurrentUser.user, status: "pending", upgrade_type: params[:upgrade_type], payment_processor: params[:payment_processor]) @user_upgrade = authorize UserUpgrade.create(recipient: recipient, purchaser: CurrentUser.user, status: "pending", upgrade_type: params[:upgrade_type], payment_processor: params[:payment_processor])
@country = params[:country] || CurrentUser.country || "US" @country = params[:country] || "US"
@allow_promotion_codes = params[:promo].to_s.truthy? @allow_promotion_codes = params[:promo].to_s.truthy?
@checkout = @user_upgrade.create_checkout!(country: @country, allow_promotion_codes: @allow_promotion_codes) @checkout = @user_upgrade.create_checkout!(country: @country, allow_promotion_codes: @allow_promotion_codes)

View File

@@ -82,7 +82,6 @@ class DanbooruLogger
name: user&.name, name: user&.name,
level: user&.level_string, level: user&.level_string,
#ip: request.remote_ip, #ip: request.remote_ip,
#country: CurrentUser.country,
#safe_mode: CurrentUser.safe_mode?, #safe_mode: CurrentUser.safe_mode?,
#bot: UserAgent.new(request.headers["HTTP_USER_AGENT"]).is_bot?, #bot: UserAgent.new(request.headers["HTTP_USER_AGENT"]).is_bot?,
} }

View File

@@ -58,9 +58,9 @@ class SessionLoader
# resetting a password from an magic email link) # resetting a password from an magic email link)
# #
# Also performs post-load actions, including updating the user's last login # Also performs post-load actions, including updating the user's last login
# timestamp, their last used IP, their timezone, their database timeout, their # timestamp, their last used IP, their timezone, their database timeout,
# country, whether safe mode is enabled, their session cookie, and unbanning # whether safe mode is enabled, their session cookie, and unbanning banned
# banned users if their ban is expired. # users if their ban is expired.
# #
# @see ApplicationController#set_current_user # @see ApplicationController#set_current_user
# @see CurrentUser # @see CurrentUser
@@ -79,7 +79,6 @@ class SessionLoader
update_last_logged_in_at update_last_logged_in_at
update_last_ip_addr update_last_ip_addr
set_time_zone set_time_zone
set_country
set_safe_mode set_safe_mode
set_save_data_mode set_save_data_mode
initialize_session_cookies initialize_session_cookies
@@ -168,12 +167,6 @@ class SessionLoader
Time.zone = CurrentUser.user.time_zone Time.zone = CurrentUser.user.time_zone
end end
# Depends on Cloudflare
# https://support.cloudflare.com/hc/en-us/articles/200168236-Configuring-Cloudflare-IP-Geolocation
def set_country
CurrentUser.country = request.headers["CF-IPCountry"]
end
def set_safe_mode def set_safe_mode
safe_mode = request.host.in?(Danbooru.config.safe_mode_hostnames) || params[:safe_mode].to_s.truthy? || CurrentUser.user.enable_safe_mode? safe_mode = request.host.in?(Danbooru.config.safe_mode_hostnames) || params[:safe_mode].to_s.truthy? || CurrentUser.user.enable_safe_mode?
CurrentUser.safe_mode = safe_mode CurrentUser.safe_mode = safe_mode