Sha256: 7fbd2c98783a0bd7f258504b7c05b9aa24443cbe569b6998f2e222afb5f8a8bc
Contents?: true
Size: 989 Bytes
Versions: 34
Compression:
Stored size: 989 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 feature ActionAuthorizer.new(user, feature, action).authorize.ok? end def feature feature = context.fetch(:current_feature, nil) return nil unless feature && feature.manifest.name == :meetings feature end end end end end
Version data entries
34 entries across 34 versions & 2 rubygems