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, :permitted_auth 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 if SelfAuthRails.permitted_auth.nil? SelfAuthRails.permitted_auth ||= Proc.new { |selfid| true } end 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 end