Sha256: 60626af1609cfdc5bcaf65971f2ed93ea66d5282cd349159ee08e8970b14cb56

Contents?: true

Size: 744 Bytes

Versions: 64

Compression:

Stored size: 744 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class UserManagerPermissions < DefaultPermissions
    def permissions
      if user_manager?
        allow! if read_admin_dashboard_action?
        allow! if impersonate_managed_user_action?
      end

      permission_action
    end

    private

    def read_admin_dashboard_action?
      permission_action.subject == :admin_dashboard &&
        permission_action.action == :read
    end

    def impersonate_managed_user_action?
      permission_action.subject == :managed_user &&
        permission_action.action == :impersonate
    end

    # Whether the user has the user_manager role or not.
    def user_manager?
      user && !user.admin? && user.role?("user_manager")
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.28.4 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.27.9 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.29.0 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.28.3 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.27.8 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.29.0.rc4 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.29.0.rc3 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.29.0.rc2 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.29.0.rc1 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.28.2 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.27.7 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.28.1 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.27.6 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.26.10 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.26.9 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.28.0 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.27.5 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.28.0.rc5 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.28.0.rc4 app/permissions/decidim/user_manager_permissions.rb