Class: Dbhero::ApplicationController

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

Direct Known Subclasses

DataclipsController

Instance Method Summary collapse

Instance Method Details

#_current_userObject



15
16
17
18
19
# File 'app/controllers/dbhero/application_controller.rb', line 15

def _current_user
  if Dbhero.authenticate && Dbhero.current_user_method.present?
    send(Dbhero.current_user_method)
  end
end

#call_custom_authObject



21
22
23
24
25
26
27
28
# File 'app/controllers/dbhero/application_controller.rb', line 21

def call_custom_auth
  cond = Dbhero.custom_user_auth_condition
  if cond.present? && cond.is_a?(Proc)
    cond.call(_current_user)
  else
    true
  end
end

#check_authObject



3
4
5
6
7
8
9
# File 'app/controllers/dbhero/application_controller.rb', line 3

def check_auth
  if Dbhero.authenticate
    unless _current_user && call_custom_auth
      raise ActionController::RoutingError.new('Forbidden')
    end
  end
end

#user_representationObject



11
12
13
# File 'app/controllers/dbhero/application_controller.rb', line 11

def user_representation
  _current_user.send(Dbhero.user_representation) if _current_user
end