Class: ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
frontend/app/controllers/application_controller.rb,
public/app/controllers/application_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.can_access?(context, method) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
46
47
48
49
50
51
# File 'frontend/app/controllers/application_controller.rb', line 43

def self.can_access?(context, method)
  permission_mappings.each do |permission, actions|
    if actions.include?(method) && !session_can?(context, permission)
      return false
    end
  end

  return true
end

.permission_mappingsObject



39
40
41
# File 'frontend/app/controllers/application_controller.rb', line 39

def self.permission_mappings
  Array(@permission_mappings)
end

.set_access_control(permission_mappings) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'frontend/app/controllers/application_controller.rb', line 54

def self.set_access_control(permission_mappings)
  @permission_mappings = permission_mappings

  skip_before_action :unauthorised_access, :only => Array(permission_mappings.values).flatten.uniq

  permission_mappings.each do |permission, actions|
    next if permission === :public

    before_action(:only => Array(actions)) {|c| user_must_have(permission)}
  end
end

Instance Method Details

#archivesspaceObject



41
42
43
# File 'public/app/controllers/application_controller.rb', line 41

def archivesspace
  ArchivesSpaceClient.instance
end