Sha256: aacac384eb57826e94ac8f62f44affd0ebad5269f6ab7e0ecf99f6c1aead3445
Contents?: true
Size: 1005 Bytes
Versions: 3
Compression:
Stored size: 1005 Bytes
Contents
# frozen_string_literal: true module Decidim module Meetings module Abilities # Defines the abilities related to meetings for a logged in user. # Intended to be used with `cancancan`. class CurrentUserAbility include CanCan::Ability attr_reader :user, :context def initialize(user, context) return unless user @user = user @context = context can :join, Meeting do |meeting| authorized?(:join) && meeting.registrations_enabled? end can :leave, Meeting, &:registrations_enabled? end private def authorized?(action) return unless component ActionAuthorizer.new(user, component, action).authorize.ok? end def component component = context.fetch(:current_component, nil) return nil unless component && component.manifest.name == :meetings component end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems