Sha256: 57237e092f2943d5cad9939351dcf5ec07092a52e3d1af35c3ba27e77481c632

Contents?: true

Size: 833 Bytes

Versions: 13

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

class RestrictedAreaController < BaseEditingBootstrap.inherited_controller.constantize
  include Pundit::Authorization
  after_action :verify_authorized
  after_action :verify_policy_scoped, only: :index
  rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized


  # :nocov:
  # Essendo un placeholder per after_action andiamo a non doverlo coprire con il coverage, se viene richiamato fallisce.
  def index
    raise "NOT implemented"
  end

  # :nocov:

  private

  def user_not_authorized(exception)
    Rails.logger.debug{"Pundit::NotAuthorizedError [#{exception.message}]"}
    policy_name = exception.policy.class.to_s.underscore

    flash[:error] = t "#{policy_name}.#{exception.query}", scope: "pundit", default: :default
    redirect_back(fallback_location: root_path)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
base_editing_bootstrap-1.6.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-1.5.1 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-1.5.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-1.4.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-1.3.2 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-1.3.1 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-1.3.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-1.2.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-1.1.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-1.0.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.16.1 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.16.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.15.0 app/controllers/restricted_area_controller.rb