Sha256: eaf8223c23ac0da5f859aba17b845048fb19ab4525eb566e5378e057ef7857f9

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module Decidim
  class AuthorizationModalsController < Decidim::ApplicationController
    helper_method :authorizations, :authorize_action_path
    layout false

    def show; end

    private

    def resource
      @resource ||= if params[:resource_name] && params[:resource_id]
                      manifest = Decidim.find_resource_manifest(params[:resource_name])
                      manifest&.resource_scope(current_component)&.find_by(id: params[:resource_id])
                    end
    end

    def current_component
      @current_component ||= Decidim::Component.where(participatory_space: current_organization.participatory_spaces).find(params[:component_id])
    end

    def authorization_action
      @authorization_action ||= params[:authorization_action]
    end

    def authorize_action_path(handler_name)
      authorizations.status_for(handler_name).current_path(redirect_url: URI(request.referer).path)
    end

    def authorizations
      @authorizations ||= action_authorized_to(authorization_action, resource: resource)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/controllers/decidim/authorization_modals_controller.rb
decidim-core-0.27.8 app/controllers/decidim/authorization_modals_controller.rb
decidim-core-0.27.7 app/controllers/decidim/authorization_modals_controller.rb
decidim-core-0.27.6 app/controllers/decidim/authorization_modals_controller.rb
decidim-core-0.26.10 app/controllers/decidim/authorization_modals_controller.rb
decidim-core-0.26.9 app/controllers/decidim/authorization_modals_controller.rb
decidim-core-0.27.5 app/controllers/decidim/authorization_modals_controller.rb
decidim-core-0.26.8 app/controllers/decidim/authorization_modals_controller.rb
decidim-core-0.27.4 app/controllers/decidim/authorization_modals_controller.rb