1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-30 19:52:20 +01:00
fab-manager/app/policies/cart_policy.rb
2022-08-25 08:52:17 +02:00

21 lines
447 B
Ruby

# frozen_string_literal: true
# Check the access policies for API::CartController
class CartPolicy < ApplicationPolicy
def create?
true
end
def set_customer?
user.privileged?
end
%w[add_item remove_item set_quantity].each do |action|
define_method "#{action}?" do
return user.privileged? || (record.statistic_profile_id == user.statistic_profile.id) if user
record.statistic_profile_id.nil?
end
end
end