Sha256: ab983510b48d27c05569e0fbe223b88689e94bc81a563af3c5db1db5c4204dcf

Contents?: true

Size: 765 Bytes

Versions: 3

Compression:

Stored size: 765 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  # Shared behaviour for controllers that need an organization present in order
  # to work. The organization is injected via the CurrentOrganization
  # middleware.
  module NeedsOrganization
    extend ActiveSupport::Concern

    included do
      before_action :verify_organization
      helper_method :current_organization

      # The current organization for the request.
      #
      # Returns an Organization.
      def current_organization
        @current_organization ||= request.env["decidim.current_organization"]
      end

      private

      def verify_organization
        redirect_to decidim_system.root_path unless current_organization
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-core-0.4.2 app/controllers/concerns/decidim/needs_organization.rb
decidim-core-0.4.1 app/controllers/concerns/decidim/needs_organization.rb
decidim-core-0.4.0 app/controllers/concerns/decidim/needs_organization.rb