Sha256: 4336770f5b0ff711aa7c1addf26d2347ae3b96155c20b1e2847f858f52abab2b

Contents?: true

Size: 812 Bytes

Versions: 5

Compression:

Stored size: 812 Bytes

Contents

module Locomotive
  module Ecommerce
    class ApplicationController < ::ActionController::Base
      include ::Locomotive::Ecommerce::EcommerceHelper

      before_filter :set_current_site

      def authenticate_user!
        if current_user(self) == nil
          flash[:error] = "Authentication needed.  Please log in to continue."
          redirect_to cart_path
        end
      end

      def locomotive_user?
        locomotive_account_signed_in?
      end

      private

      def fetch_site
        if Locomotive.config.multi_sites?
          @current_site ||= ::Locomotive::Site.match_domain(request.host).first
        else
          @current_site ||= ::Locomotive::Site.first
        end
      end

      def set_current_site
        Thread.current[:site] = fetch_site
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
locomotive_ecommerce_plugin-1.0.6 app/controllers/locomotive/ecommerce/application_controller.rb
locomotive_ecommerce_plugin-1.0.5 app/controllers/locomotive/ecommerce/application_controller.rb
locomotive_ecommerce_plugin-1.0.4 app/controllers/locomotive/ecommerce/application_controller.rb
locomotive_ecommerce_plugin-1.0.1 app/controllers/locomotive/ecommerce/application_controller.rb
locomotive_ecommerce_plugin-1.0.0 app/controllers/locomotive/ecommerce/application_controller.rb