Class: Decidim::Admin::OrganizationDashboardConstraint

Inherits:
Object
  • Object
show all
Defined in:
decidim-admin/app/constraints/decidim/admin/organization_dashboard_constraint.rb

Overview

A Rails routes constraint to only allow access to an Organization admin to the organization dashboard.

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ OrganizationDashboardConstraint

Initializes the contraint.

request [Rack::Request]


11
12
13
# File 'decidim-admin/app/constraints/decidim/admin/organization_dashboard_constraint.rb', line 11

def initialize(request)
  @request = request
end

Instance Method Details

#matches?Boolean

Checks if the user can access the organization dashboard.

Returns boolean.

Returns:

  • (Boolean)

18
19
20
# File 'decidim-admin/app/constraints/decidim/admin/organization_dashboard_constraint.rb', line 18

def matches?
  user && user.organization == organization && user_has_permission_to_access_dashboard?
end