Class: AdminSuite::Auth::HostHook

Inherits:
Strategy
  • Object
show all
Defined in:
lib/admin_suite/auth/host_hook.rb

Overview

Back-compat wrapper for the legacy config.authenticate lambda.

Legacy lambdas deny by rendering/redirecting on the controller themselves; success is "the lambda returned without halting".

Instance Attribute Summary

Attributes inherited from Strategy

#options

Instance Method Summary collapse

Methods inherited from Strategy

#initialize

Constructor Details

This class inherits a constructor from AdminSuite::Auth::Strategy

Instance Method Details

#authenticate!(controller) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/admin_suite/auth/host_hook.rb', line 10

def authenticate!(controller)
  options[:authenticate].call(controller)
  return nil if controller.performed?

  actor_hook = options[:current_actor]
  actor =
    begin
      actor_hook&.call(controller)
    rescue StandardError
      nil
    end
  actor || true # authenticated, anonymous actor
end