Sha256: 914d6fff0019602c6e00a698a2d2fd539b637ef4f787e2efa4c6dc857d7cc91a

Contents?: true

Size: 1.53 KB

Versions: 8

Compression:

Stored size: 1.53 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

    layout '/locomotive/layouts/application'

    before_filter :require_ssl

    before_filter :require_account

    before_filter :require_site

    before_filter :validate_site_membership

    load_and_authorize_resource

    before_filter :set_back_office_locale

    before_filter :set_current_content_locale

    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_url
      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 ||= Ability.new(current_locomotive_account, current_site)
    end

    def require_account
      authenticate_locomotive_account!
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locomotive_cms-2.2.2 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.2.1 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.2.0 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.1.4 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.1.3 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.1.2 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.1.1 app/controllers/locomotive/base_controller.rb
locomotive_cms-2.1.0 app/controllers/locomotive/base_controller.rb