Module: Decidim::AnonymousProposals::PermissionsOverrides

Extended by:
ActiveSupport::Concern
Defined in:
app/permissions/decidim/anonymous_proposals/permissions_overrides.rb

Overview

Method overrides to avoid errors when current_user is not present

Instance Method Summary collapse

Instance Method Details

#permissionsObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/permissions/decidim/anonymous_proposals/permissions_overrides.rb', line 9

def permissions
  return permission_action unless user_or_anonymous_action?(permission_action)

  # Delegate the admin permission checks to the admin permissions class
  return Decidim::Proposals::Admin::Permissions.new(user, permission_action, context).permissions if permission_action.scope == :admin
  return permission_action if permission_action.scope != :public

  case permission_action.subject
  when :proposal
    apply_proposal_permissions(permission_action)
  when :collaborative_draft
    apply_collaborative_draft_permissions(permission_action)
  else
    permission_action
  end

  permission_action
end