Sha256: 64dc0a970fca94674e740c70a74d74bd4602cb14a8f9b3f88fdc8e0c4d29d884

Contents?: true

Size: 775 Bytes

Versions: 2

Compression:

Stored size: 775 Bytes

Contents

# frozen_string_literal: true

module SolidusSubscriptions
  module PermissionSets
    class DefaultCustomer < ::Spree::PermissionSets::Base
      def activate!
        can [:show, :display, :update, :skip, :cancel], Subscription, ['user_id = ?', user.id] do |subscription, guest_token|
          (subscription.guest_token.present? && subscription.guest_token == guest_token) ||
            (subscription.user && subscription.user == user)
        end

        can [:show, :display, :update, :destroy], LineItem do |line_item, guest_token|
          (line_item.subscription&.guest_token.present? && line_item.subscription.guest_token == guest_token) ||
            (line_item.subscription&.user && line_item.subscription.user == user)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_subscriptions-1.0.0 lib/solidus_subscriptions/permission_sets/default_customer.rb
solidus_subscriptions-1.0.0.rc1 lib/solidus_subscriptions/permission_sets/default_customer.rb