summaryrefslogtreecommitdiff
path: root/lib/solidus_subscriptions/permission_sets/subscription_management.rb
blob: 76c1e94d95bf3a1117da64b85a33faf533d846f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

module SolidusSubscriptions
  module PermissionSets
    class SubscriptionManagement < ::Spree::PermissionSets::Base
      def activate!
        can :manage, Subscription do |subscription|
          subscription.user && subscription.user == user
        end

        can :manage, LineItem do |line_item|
          line_item.subscription&.user && line_item.subscription.user == user
        end
      end
    end
  end
end