Sha256: 0c14943121510be815f876814d0e8cc3899eb4809aee7ad232279666297caae6

Contents?: true

Size: 698 Bytes

Versions: 33

Compression:

Stored size: 698 Bytes

Contents

module Locomotive
  module Concerns
    module AuthorizationController

      extend ActiveSupport::Concern
      include Pundit

      included do
        rescue_from Pundit::NotAuthorizedError, with: :render_access_denied
      end

      private

      def render_access_denied(exception)
        ::Locomotive.log "[AccessDenied] #{exception.inspect}"

        if request.xhr?
          render json: { error: exception.message }, status: 401, layout: false
        else
          flash[:alert] = exception.message
          redirect_to current_site? ? dashboard_path(current_site) : sites_path
        end
      end

      def pundit_user
        current_membership
      end

    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
locomotivecms-4.0.0.rc0 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-4.0.0.alpha3 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.4.1 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-4.0.0.alpha2 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-4.0.0.alpha1 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.4.0 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.3.0 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.3.0.rc3 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.3.0.rc2 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.1.2 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.2.1 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.3.0.rc1 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.2.0 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.2.0.rc2 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.2.0.rc1 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.1.1 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.1.0 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.1.0.rc3 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.1.0.rc2 app/controllers/locomotive/concerns/authorization_controller.rb
locomotivecms-3.1.0.rc1 app/controllers/locomotive/concerns/authorization_controller.rb