Sha256: d7820585ed35c013c6502f710898de0ce58cd10e9ee625a8c8a7b963a9d4f37c
Contents?: true
Size: 886 Bytes
Versions: 9
Compression:
Stored size: 886 Bytes
Contents
# frozen_string_literal: true require "active_support/concern" module Decidim module ActionAuthorization extend ActiveSupport::Concern included do helper_method :action_authorized_to end private def action_authorized_to(action, resource: nil) action_authorization_cache[action_authorization_cache_key(action, resource)] ||= ::Decidim::ActionAuthorizer.new(current_user, action, resource&.component || current_component, resource).authorize end def action_authorization_cache request.env["decidim.action_authorization_cache"] ||= {} end def action_authorization_cache_key(action, resource) if resource && !resource.permissions.nil? "#{action}-#{resource.component.id}-#{resource.resource_manifest.name}-#{resource.id}" else "#{action}-#{current_component.id}" end end end end
Version data entries
9 entries across 9 versions & 1 rubygems