Sha256: c7ad12d14d8de447ae9201c9a90bacb52773ee617a2c005a027649588d2d2184

Contents?: true

Size: 1007 Bytes

Versions: 46

Compression:

Stored size: 1007 Bytes

Contents

require 'fiona7/editing_env_check'

module Fiona7
  class AccessPermissionCheck
    def initialize(obj, env, rc_user, reactor_user)
      self.obj = obj
      self.env = env
      self.rc_user = rc_user
      self.reactor_user = reactor_user
    end

    def read_permitted?
      if edited_contents_visible?
        read_permission_check
      else
        live_permission_check 
      end
    end

    protected
    attr_accessor :obj, :env, :rc_user, :reactor_user
    
    def edited_contents_visible?
      Fiona7::EditingEnvCheck.new(self.env).rtc_selected?
    end

    # this is very quick!
    def live_permission_check
      self.obj.permitted_for_user?(self.rc_user)
    end

    # this is very slow!
    def read_permission_check
      if !self.reactor_user
        false
      else
        self.reactor_user.superuser? ||
          (self.obj.permissions.root & self.reactor_user.groups).any? ||
          (self.obj.permissions.read & self.reactor_user.groups).any?
      end
    end

  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
infopark_fiona7-1.2.0.0.0 lib/fiona7/access_permission_check.rb
infopark_fiona7-1.1.0.0.9 lib/fiona7/access_permission_check.rb
infopark_fiona7-1.1.0.0.8 lib/fiona7/access_permission_check.rb
infopark_fiona7-1.1.0.0.7 lib/fiona7/access_permission_check.rb
infopark_fiona7-1.1.0.0.6 lib/fiona7/access_permission_check.rb
infopark_fiona7-1.1.0.0.5 lib/fiona7/access_permission_check.rb
infopark_fiona7-1.1.0.0.4 lib/fiona7/access_permission_check.rb
infopark_fiona7-1.1.0.0.3 lib/fiona7/access_permission_check.rb
infopark_fiona7-1.1.0.0.2 lib/fiona7/access_permission_check.rb
infopark_fiona7-1.1.0.0.10 lib/fiona7/access_permission_check.rb
infopark_fiona7-1.1.0.0.1 lib/fiona7/access_permission_check.rb
infopark_fiona7-1.1.0.0.0 lib/fiona7/access_permission_check.rb
infopark_fiona7-0.71.1.9 lib/fiona7/access_permission_check.rb
infopark_fiona7-0.71.1.8 lib/fiona7/access_permission_check.rb
infopark_fiona7-0.71.1.7 lib/fiona7/access_permission_check.rb
infopark_fiona7-0.71.1.6 lib/fiona7/access_permission_check.rb
infopark_fiona7-0.71.1.5 lib/fiona7/access_permission_check.rb
infopark_fiona7-0.71.1.4 lib/fiona7/access_permission_check.rb
infopark_fiona7-0.71.1.3 lib/fiona7/access_permission_check.rb
infopark_fiona7-0.71.1.2 lib/fiona7/access_permission_check.rb