blob: 6ce4b2d41207a7cbae5233caec013c1a64b4f4b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# frozen_string_literal: true
module SolidusSubscriptions
class Ability
include CanCan::Ability
def initialize(user)
alias_action :create, :read, :update, :destroy, to: :crud
if user.has_spree_role?('admin')
can(:manage, LineItem)
can(:manage, Subscription)
else
can([:crud, :skip, :cancel], Subscription, user_id: user.id)
can(:crud, LineItem) do |li, order|
li.order.user == user || li.order == order
end
end
end
end
end
|