Skip to content

Commit

Permalink
Remove spree alerts feature that would check spree website for securi…
Browse files Browse the repository at this point in the history
…ty alerts

This is not something we need running such an old version of spree
  • Loading branch information
luisramos0 committed Dec 3, 2019
1 parent 2248627 commit fce402a
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .rubocop_manual_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ Metrics/LineLength:
- app/controllers/application_controller.rb
- app/controllers/checkout_controller.rb
- app/controllers/spree/admin/adjustments_controller_decorator.rb
- app/controllers/spree/admin/base_controller_decorator.rb
- app/controllers/spree/admin/orders_controller_decorator.rb
- app/controllers/spree/admin/payments_controller_decorator.rb
- app/controllers/spree/admin/reports_controller_decorator.rb
Expand Down Expand Up @@ -646,6 +645,7 @@ Metrics/ClassLength:
- app/controllers/admin/subscriptions_controller.rb
- app/controllers/api/products_controller.rb
- app/controllers/checkout_controller.rb
- app/controllers/spree/admin/base_controller.rb
- app/controllers/spree/admin/payment_methods_controller.rb
- app/controllers/spree/admin/users_controller.rb
- app/controllers/spree/orders_controller.rb
Expand Down
31 changes: 0 additions & 31 deletions app/controllers/spree/admin/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class BaseController < Spree::BaseController

include I18nHelper

before_filter :check_alerts
before_filter :authorize_admin
before_filter :set_locale
before_filter :warn_invalid_order_cycles, if: :html_request?
Expand Down Expand Up @@ -77,29 +76,6 @@ def generate_admin_api_key
user.generate_spree_api_key!
end

def check_alerts
return unless should_check_alerts?

return if session.key? :alerts

begin
session[:alerts] = Spree::Alert.current(request.host)
filter_dismissed_alerts
Spree::Config.set last_check_for_spree_alerts: DateTime.now.in_time_zone.to_s
rescue
session[:alerts] = nil
end
end

def should_check_alerts?
return false if !Rails.env.production? || !Spree::Config[:check_for_spree_alerts]

last_check = Spree::Config[:last_check_for_spree_alerts]
return true if last_check.blank?

DateTime.parse(last_check).in_time_zone < 12.hours.ago
end

def flash_message_for(object, event_sym)
resource_desc = object.class.model_name.human
resource_desc += " \"#{object.name}\"" if object.respond_to?(:name) && object.name.present?
Expand All @@ -122,13 +98,6 @@ def check_json_authenticity
raise(ActionController::InvalidAuthenticityToken)
end

def filter_dismissed_alerts
return unless session[:alerts]

dismissed = (Spree::Config[:dismissed_spree_alerts] || '').split(',')
session[:alerts].reject! { |a| dismissed.include? a["id"].to_s }
end

def config_locale
Spree::Backend::Config[:locale]
end
Expand Down
15 changes: 1 addition & 14 deletions app/controllers/spree/admin/general_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ def edit
@preferences_general = [:site_name, :default_seo_title, :default_meta_keywords,
:default_meta_description, :site_url, :bugherd_api_key]
@preferences_security = [:allow_ssl_in_production,
:allow_ssl_in_staging, :allow_ssl_in_development_and_test,
:check_for_spree_alerts]
:allow_ssl_in_staging, :allow_ssl_in_development_and_test]
@preferences_currency = [:display_currency, :hide_cents]
end

Expand All @@ -20,18 +19,6 @@ def update

redirect_to edit_admin_general_settings_path
end

def dismiss_alert
return unless request.xhr? && params[:alert_id]

dismissed = Spree::Config[:dismissed_spree_alerts] || ''
Spree::Config.set(dismissed_spree_alerts: dismissed.
split(',').
push(params[:alert_id]).
join(','))
filter_dismissed_alerts
render nothing: true
end
end
end
end
2 changes: 0 additions & 2 deletions app/views/spree/layouts/_admin_body.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
= Spree.t(:loading)
\...
= render :partial => 'spree/admin/shared/alert', :collection => session[:alerts]
%header#header{"data-hook" => ""}
.container
%figure.columns.five{"data-hook" => "logo-wrapper"}
Expand Down
1 change: 0 additions & 1 deletion app/views/spree/layouts/bare_admin.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
.progress-message
= t(:loading)
\...
= render :partial => 'spree/admin/shared/alert', :collection => session[:alerts]
%header#header{"data-hook" => ""}
.container
Expand Down
1 change: 0 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2850,7 +2850,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using
allow_ssl_in_development_and_test: "Allow SSL to be used when in development and test modes"
allow_ssl_in_production: "Allow SSL to be used in production mode"
allow_ssl_in_staging: "Allow SSL to be used in staging mode"
check_for_spree_alerts: "Check for Spree alerts"
currency_decimal_mark: "Currency decimal mark"
currency_settings: "Currency Settings"
currency_symbol_position: Put "currency symbol before or after dollar amount?"
Expand Down
6 changes: 1 addition & 5 deletions config/routes/spree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@
end

# Configuration section
resource :general_settings do
collection do
post :dismiss_alert
end
end
resource :general_settings
resource :mail_method, :only => [:edit, :update] do
post :testmail, :on => :collection
end
Expand Down

0 comments on commit fce402a

Please sign in to comment.