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-3.2.9 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.2.8 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.2.7 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.2.6 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.1.9 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.2.5 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.2.4 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.2.3 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.1.8 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.0.8 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.2.2 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.2.1 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.2.0 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.2.0.alpha app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.0.7 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-2.11.17 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.1.7 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-2.11.16 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.0.6 app/models/spree/user_last_url_storer/rules/authentication_rule.rb
solidus_core-3.1.6 app/models/spree/user_last_url_storer/rules/authentication_rule.rb