Class: Decidim::Admin::OrganizationDashboardConstraint

Inherits:
Object
  • Object
show all
Defined in:
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 constraint.

request [Rack::Request]



11
12
13
# File '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 'app/constraints/decidim/admin/organization_dashboard_constraint.rb', line 18

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