Sha256: 5ab0bee901279025d03d5f40db2f90ece014e4f1a214ea434c0519cfdfc9001c

Contents?: true

Size: 934 Bytes

Versions: 2

Compression:

Stored size: 934 Bytes

Contents

module Comable
  module Admin
    class ApplicationController < ActionController::Base
      include Comable::ApplicationHelper

      # Include `asset_path` method for gritter
      helper Sprockets::Helpers::RailsHelper if Rails::VERSION::MAJOR == 3

      layout 'comable/admin/application'

      def current_ability
        Comable::Ability.new(current_customer)
      end

      private

      rescue_from CanCan::AccessDenied, with: :unauthorized

      def unauthorized
        if current_customer.signed_in?
          flash[:alert] = Comable.t('admin.access_denied')
          redirect_to after_access_denied_path
        else
          store_location
          redirect_to comable.new_admin_customer_session_path
        end
      end

      def after_access_denied_path
        if current_customer.customer?
          comable.root_path
        else
          comable.admin_root_path
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
comable_backend-0.3.4 app/controllers/comable/admin/application_controller.rb
comable_backend-0.3.3 app/controllers/comable/admin/application_controller.rb