Class: OnboardOnRails::Api::BaseController

Inherits:
OnboardOnRails::ApplicationController show all
Defined in:
app/controllers/onboard_on_rails/api/base_controller.rb

Instance Method Summary collapse

Instance Method Details

#current_userObject



7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/onboard_on_rails/api/base_controller.rb', line 7

def current_user
  @current_user ||= begin
    method_name = OnboardOnRails.configuration.current_user_method
    host_controller = ::ApplicationController.new
    host_controller.request = request if host_controller.respond_to?(:request=)
    host_controller.send(method_name) if host_controller.respond_to?(method_name, true)
  rescue => e
    Rails.logger.error "[OnboardOnRails] Failed to get current_user: #{e.message}"
    nil
  end
end