Sha256: ba5ae1989cfe29cad8df8b30d1ee79494468e58f215dbe99e9b939fc88f446be

Contents?: true

Size: 1.04 KB

Versions: 54

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Spree
  class UserLastUrlStorer
    module Rules
      # This is the basic rule that ships with Solidus that avoids storing in
      # session the current path for login/loout/signup routes, avoiding possibly
      # infinte redirects.
      module AuthenticationRule
        AUTHENTICATION_ROUTES = %w[spree_signup_path spree_login_path spree_logout_path]

        extend self

        def match?(controller)
          full_path = controller.request.fullpath
          disallowed_urls(controller).include?(full_path)
        end

        private

        def disallowed_urls(controller)
          @disallowed_urls ||= {}
          @disallowed_urls[controller.controller_name] ||= begin
            [].tap do |disallowed_urls|
              AUTHENTICATION_ROUTES.each do |route|
                if controller.respond_to?(route)
                  disallowed_urls << controller.send(route)
                end
              end
            end.map! { |url| url[/\/\w+$/] }
          end
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
solidus_core-2.11.15 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-2.11.14 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.0.5 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.1.5 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-2.11.13 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.0.4 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.1.4 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-2.11.12 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.0.3 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.1.3 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.1.2 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.1.1 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.1.0 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-2.11.11 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.0.2 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-2.10.5 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-2.11.10 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.0.1 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.0.0 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-2.11.9 app/models/spree/user_last_url_storer/rules/authentication_rule.rb