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.20.1 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.20.0 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.19.1 app/permissions/decidim/user_manager_permissions.rb
decidim-core-0.19.0 app/permissions/decidim/user_manager_permissions.rb