Sha256: 552636dafeff0ba5b8547c1300bf101ed77dfe5a8c2408fe8007ff1bcb604f60

Contents?: true

Size: 498 Bytes

Versions: 9

Compression:

Stored size: 498 Bytes

Contents

module Locomotive
  class AccountPolicy < ApplicationPolicy

    def index?
      super_admin?
    end

    def show?
      super_admin? || owner?
    end

    def create?
      # everybody can create an account
      true
    end

    def update?
      (super_admin? || owner?) && !@resource.visitor?
    end

    def destroy?
      # can not delete himself/herself
      super_admin? && !owner?
    end

    private

    def owner?
      @resource._id == membership.account_id
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 app/policies/locomotive/account_policy.rb
locomotivecms-4.2.0.alpha1 app/policies/locomotive/account_policy.rb
locomotivecms-4.1.1 app/policies/locomotive/account_policy.rb
locomotivecms-4.1.0 app/policies/locomotive/account_policy.rb
locomotivecms-4.1.0.rc1 app/policies/locomotive/account_policy.rb
locomotivecms-4.0.3 app/policies/locomotive/account_policy.rb
locomotivecms-4.0.2 app/policies/locomotive/account_policy.rb
locomotivecms-4.0.1 app/policies/locomotive/account_policy.rb
locomotivecms-4.0.0 app/policies/locomotive/account_policy.rb