Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 12 commits
  • 8 files changed
  • 0 comments
  • 1 contributor
1  Gemfile
@@ -2,6 +2,7 @@ source 'http://rubygems.org'
2 2
3 3 gem 'json'
4 4 gem 'sqlite3'
  5 +
5 6 # Gems used only for assets and not required
6 7 # in production environments by default.
7 8 group :assets do
1  core/app/controllers/spree/base_controller.rb
... ... @@ -1,4 +1,5 @@
1 1 class Spree::BaseController < ActionController::Base
2 2 include SpreeBase
3 3 include SpreeRespondWith
  4 + include ::SslRequirement
4 5 end
8 core/app/models/order.rb
@@ -103,12 +103,8 @@ def item_count
103 103 before_transition :to => 'complete' do |order|
104 104 begin
105 105 order.process_payments!
106   - rescue Spree::GatewayError
107   - if Spree::Config[:allow_checkout_on_gateway_error]
108   - true
109   - else
110   - false
111   - end
  106 + rescue Spree::GatewayError => ex
  107 + order.errors.add(:base, ex.message)
112 108 end
113 109 end
114 110
2  core/config/initializers/spree.rb
... ... @@ -1,5 +1,7 @@
1 1 require 'mail'
2 2
  3 +require 'ssl_requirement'
  4 +
3 5 # Spree Configuration
4 6 SESSION_KEY = '_spree_session_id'
5 7 #require 'spree/support/core_ext/array/conversions'
5 core/lib/spree_base.rb
... ... @@ -1,5 +1,7 @@
1 1 module SpreeBase
2 2 module InstanceMethods
  3 +
  4 +
3 5 def access_forbidden
4 6 render :text => 'Access Forbidden', :layout => true, :status => 401
5 7 end
@@ -121,7 +123,8 @@ def self.included(receiver)
121 123 receiver.send :helper_method, 'get_taxonomies'
122 124 receiver.send :helper_method, 'current_gateway'
123 125 receiver.send :helper_method, 'current_order'
124   - receiver.send :include, SslRequirement
125 126 receiver.send :include, Spree::CurrentOrder
  127 + receiver.send :include, ::SslRequirement
  128 +
126 129 end
127 130 end
1  core/lib/spree_core.rb
@@ -53,7 +53,6 @@
53 53 require 'spree_core/spree_respond_with'
54 54
55 55
56   -require 'spree_core/ssl_requirement'
57 56 require 'spree_core/preferences/model_hooks'
58 57 require 'spree_core/preferences/preference_definition'
59 58 require 'store_helpers'
104 core/lib/spree_core/ssl_requirement.rb
... ... @@ -1,104 +0,0 @@
1   -# ++
2   -# Copyright (c) 2007-2011, Rails Dog LLC and other contributors
3   -# All rights reserved.
4   -#
5   -# Redistribution and use in source and binary forms, with or without modification,
6   -# are permitted provided that the following conditions are met:
7   -#
8   -# * Redistributions of source code must retain the above copyright notice,
9   -# this list of conditions and the following disclaimer.
10   -# * Redistributions in binary form must reproduce the above copyright notice,
11   -# this list of conditions and the following disclaimer in the documentation
12   -# and/or other materials provided with the distribution.
13   -# * Neither the name of the Rails Dog LLC nor the names of its
14   -# contributors may be used to endorse or promote products derived from this
15   -# software without specific prior written permission.
16   -#
17   -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18   -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19   -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20   -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21   -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22   -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23   -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24   -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25   -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26   -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27   -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28   -# --
29   -
30   -# ++
31   -# Copyright (c) 2005 David Heinemeier Hansson
32   -#
33   -# Permission is hereby granted, free of charge, to any person obtaining
34   -# a copy of this software and associated documentation files (the
35   -# "Software"), to deal in the Software without restriction, including
36   -# without limitation the rights to use, copy, modify, merge, publish,
37   -# distribute, sublicense, and/or sell copies of the Software, and to
38   -# permit persons to whom the Software is furnished to do so, subject to
39   -# the following conditions:
40   -#
41   -# The above copyright notice and this permission notice shall be
42   -# included in all copies or substantial portions of the Software.
43   -#
44   -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
45   -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
46   -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
47   -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
48   -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
49   -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
50   -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
51   -# --
52   -
53   -# Modified version of the ssl_requirement plugin by DHH
54   -module SslRequirement
55   - extend ActiveSupport::Concern
56   -
57   - included do
58   - before_filter(:ensure_proper_protocol)
59   - end
60   -
61   - module ClassMethods
62   - # Specifies that the named actions requires an SSL connection to be performed (which is enforced by ensure_proper_protocol).
63   - def ssl_required(*actions)
64   - write_inheritable_array(:ssl_required_actions, actions)
65   - end
66   -
67   - def ssl_allowed(*actions)
68   - write_inheritable_array(:ssl_allowed_actions, actions)
69   - end
70   - end
71   -
72   - protected
73   - # Returns true if the current action is supposed to run as SSL
74   - def ssl_required?
75   - actions = self.class.read_inheritable_attribute(:ssl_required_actions)
76   - return false if actions.nil?
77   - actions.empty? || actions.include?(action_name.to_sym)
78   - end
79   -
80   - def ssl_allowed?
81   - actions = self.class.read_inheritable_attribute(:ssl_allowed_actions)
82   - return false if actions.nil?
83   - actions.empty? || actions.include?(action_name.to_sym)
84   - end
85   -
86   - private
87   -
88   - def ssl_supported?
89   - return true if (Rails.env.development? or Rails.env.test?) and Spree::Config[:allow_ssl_in_development_and_test]
90   - (Rails.env.staging? or Rails.env.production?) and Spree::Config[:allow_ssl_in_production]
91   - end
92   -
93   - def ensure_proper_protocol
94   - return true if ssl_allowed?
95   - if ssl_required? && !request.ssl? && ssl_supported?
96   - redirect_to "https://" + request.host + request.fullpath
97   - flash.keep
98   - elsif request.ssl? && !ssl_required?
99   - redirect_to "http://" + request.host + request.fullpath
100   - flash.keep
101   - end
102   -
103   - end
104   -end
3  core/spree_core.gemspec
@@ -29,9 +29,10 @@ Gem::Specification.new do |s|
29 29 s.add_dependency 'faker', '= 1.0.0'
30 30 s.add_dependency 'paperclip', '= 2.5.0'
31 31 s.add_dependency 'rd_resource_controller'
32   - s.add_dependency 'meta_search', '= 1.1.1'
  32 + s.add_dependency 'meta_search', '>= 1.1.1'
33 33 s.add_dependency 'activemerchant', '= 1.17.0'
34 34 s.add_dependency 'rails'
35 35 s.add_dependency 'kaminari', '>= 0.12.4'
36 36 s.add_dependency 'deface', '>= 0.7.0'
  37 + s.add_dependency 'bartt-ssl_requirement'
37 38 end

No commit comments for this range

Something went wrong with that request. Please try again.