require "self-auth-rails/version" require "self-auth-rails/engine" module SelfAuthRails mattr_accessor :self_client, :session_class_name, :auth_facts, :fact_mapping, :authenticated_path, :authenticated_path, :layout class Engine < ::Rails::Engine default_auth_facts = [:display_name] default_authenticated_path = '/' config.after_initialize do unless SelfAuthRails::self_client.nil? SelfAuthRails.auth_facts ||= default_auth_facts SelfAuthRails.authenticated_path ||= default_authenticated_path response_manager = SelfAuthResponseManagerService.new(ActionCable.server) # Subscribe to fact responses SelfAuthRails::self_client.facts.subscribe do |auth| response_manager.process_response(auth) end # Subscribe to authentication responses SelfAuthRails::self_client.authentication.subscribe do |auth| response_manager.process_response(auth) end end end end def self.session_class class_name = session_class_name || 'User' Object.const_get(class_name) end # this function maps the vars from your app into your engine def self.setup(&block) yield self end def authenticated_path SelfAuthRails::authenticated_path || SelfAuthRails::default_authenticated_path end end