Sha256: 77c732d2b5631e1e7eca2b142b32b491f73cc7f20a15950c17a9564daddd9598

Contents?: true

Size: 1.54 KB

Versions: 28

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

module Spree
  module PermissionSets
    class DefaultCustomer < PermissionSets::Base
      def activate!
        can :read, Country
        can :read, OptionType
        can :read, OptionValue
        can :create, Order do |order, token|
          # same user, or both nil
          order.user == user ||
          # guest checkout order
          order.email.present? ||
          # via API, just like with show and update
          (order.guest_token.present? && token == order.guest_token)
        end
        can [:show, :update], Order, Order.where(user: user) do |order, token|
          order.user == user || (order.guest_token.present? && token == order.guest_token)
        end
        cannot :update, Order do |order|
          order.completed?
        end
        can :create, ReturnAuthorization do |return_authorization|
          return_authorization.order.user == user
        end
        can [:read, :update], CreditCard, user_id: user.id
        can :read, Product
        can :read, ProductProperty
        can :read, Property
        can :create, Spree.user_class
        can [:show, :update, :update_email], Spree.user_class, id: user.id
        can :read, State
        can :read, StockItem, stock_location: { active: true }
        can :read, StockLocation, active: true
        can :read, Taxon
        can :read, Taxonomy
        can [:save_in_address_book, :remove_from_address_book], Spree.user_class, id: user.id
        can [:read, :view_out_of_stock], Variant
        can :read, Zone
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
solidus_core-4.0.4 lib/spree/permission_sets/default_customer.rb
solidus_core-3.4.6 lib/spree/permission_sets/default_customer.rb
solidus_core-4.0.3 lib/spree/permission_sets/default_customer.rb
solidus_core-3.4.5 lib/spree/permission_sets/default_customer.rb
solidus_core-4.0.2 lib/spree/permission_sets/default_customer.rb
solidus_core-3.4.4 lib/spree/permission_sets/default_customer.rb
solidus_core-3.3.4 lib/spree/permission_sets/default_customer.rb
solidus_core-3.2.9 lib/spree/permission_sets/default_customer.rb
solidus_core-3.2.8 lib/spree/permission_sets/default_customer.rb
solidus_core-3.3.3 lib/spree/permission_sets/default_customer.rb
solidus_core-3.4.3 lib/spree/permission_sets/default_customer.rb
solidus_core-4.0.1 lib/spree/permission_sets/default_customer.rb
solidus_core-4.0.0 lib/spree/permission_sets/default_customer.rb
solidus_core-3.4.2 lib/spree/permission_sets/default_customer.rb
solidus_core-3.2.7 lib/spree/permission_sets/default_customer.rb
solidus_core-3.3.2 lib/spree/permission_sets/default_customer.rb
solidus_core-3.4.1 lib/spree/permission_sets/default_customer.rb
solidus_core-3.4.0 lib/spree/permission_sets/default_customer.rb
solidus_core-3.3.1 lib/spree/permission_sets/default_customer.rb
solidus_core-3.2.6 lib/spree/permission_sets/default_customer.rb