Sha256: fe3250bca8b7bad592d0e56b253a3a5d94fb452a6e1a43bf14cc062f0737b3bd

Contents?: true

Size: 810 Bytes

Versions: 3

Compression:

Stored size: 810 Bytes

Contents

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

      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

3 entries across 3 versions & 1 rubygems

Version Path
comable_backend-0.3.2 app/controllers/comable/admin/application_controller.rb
comable_backend-0.3.1 app/controllers/comable/admin/application_controller.rb
comable_backend-0.3.0 app/controllers/comable/admin/application_controller.rb