Sha256: 1af9842d251b55fa5bb0cb2686f645400901a90f1f97bcf31628b5cdc1dcf438

Contents?: true

Size: 757 Bytes

Versions: 18

Compression:

Stored size: 757 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)
    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

18 entries across 18 versions & 1 rubygems

Version Path
base_editing_bootstrap-0.14.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.13.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.12.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.11.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.10.2 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.10.1 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.10.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.9.1 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.9.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.8.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.7.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.6.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.4.1 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.4.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.3.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.2.0 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.1.4 app/controllers/restricted_area_controller.rb
base_editing_bootstrap-0.1.2 app/controllers/restricted_area_controller.rb