Sha256: c45f79bd271e3546df1518bfb4a31a00dcde8c375615872b191d21400954252d
Contents?: true
Size: 1.38 KB
Versions: 19
Compression:
Stored size: 1.38 KB
Contents
module Locomotive class ApplicationPolicy class Scope attr_reader :membership, :scope def initialize(membership, scope) @membership = membership @scope = scope end end delegate :site, :account, to: :membership attr_reader :membership, :resource # The resource is always scoped by the site defined by the membership. def initialize(membership, resource) @membership = membership @resource = resource raise Pundit::NotAuthorizedError, 'must be logged in' unless account raise Pundit::NotAuthorizedError, 'should have a resource' unless resource # if site.nil? # unless account.super_admin? || resource.is_a?(Locomotive::Account) # raise Pundit::NotAuthorizedError, 'should have a site' # end # end end def index? false end def show? index? end def edit? update? end def update? false end def new? create? end def create? false end def destroy? false end def destroy_all? false end def site_staff? membership.site.present? end def super_admin? account.super_admin? end def site_admin_or_designer? membership.admin? || membership.designer? end def site_admin? membership.admin? end end end
Version data entries
19 entries across 19 versions & 1 rubygems