Sha256: 3d373be1dd8d4bacbc339ad105f161cccd5bf8d042f3f7eaa81ab93229c82cb7

Contents?: true

Size: 1.63 KB

Versions: 15

Compression:

Stored size: 1.63 KB

Contents

module Locomotive
  class BaseController < ApplicationController

    include Locomotive::Routing::SiteDispatcher
    include Locomotive::ActionController::LocaleHelpers
    include Locomotive::ActionController::SectionHelpers
    include Locomotive::ActionController::UrlHelpers
    include Locomotive::ActionController::Ssl
    include Locomotive::ActionController::Timezone

    layout '/locomotive/layouts/application'

    before_filter :require_ssl

    before_filter :require_account

    before_filter :require_site

    before_filter :set_back_office_locale

    before_filter :set_current_content_locale

    before_filter :validate_site_membership

    load_and_authorize_resource

    around_filter :set_timezone

    before_filter :set_current_thread_variables

    helper_method :sections, :current_ability

    helper Locomotive::BaseHelper, Locomotive::ContentTypesHelper

    self.responder = Locomotive::ActionController::Responder # custom responder

    respond_to :html

    rescue_from CanCan::AccessDenied do |exception|
      ::Locomotive.log "[CanCan::AccessDenied] #{exception.inspect}"

      if request.xhr?
        render json: { error: exception.message }
      else
        flash[:alert] = exception.message

        redirect_to pages_path
      end
    end

    protected

    def set_current_thread_variables
      Thread.current[:account]  = current_locomotive_account
      Thread.current[:site]     = current_site
    end

    def current_ability
      @current_ability ||= Locomotive::Ability.new(current_locomotive_account, current_site)
    end

    def require_account
      authenticate_locomotive_account!
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
locomotive_cms-2.5.6 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.5.6.rc2 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.5.6.rc1 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.5.5 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.5.4 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.5.3 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.5.2 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.5.1 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.5.0 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.5.0.rc3 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.5.0.rc2 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.5.0.rc1 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.4.1 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.4.0 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.3.1 app/controllers/locomotive/base_controller.rb