module Sorcery::Model::Submodules::ActivityLogging
This submodule keeps track of events such as login, logout, and last activity time, per user. It helps in estimating which users are active now in the site. This cannot be determined absolutely because a user might be reading a page without clicking anything for a while. This is the model part of the submodule, which provides configuration options.
Public Class Methods
included(base)
click to toggle source
# File lib/sorcery/model/submodules/activity_logging.rb, line 10 def self.included(base) base.extend(ClassMethods) base.send(:include, InstanceMethods) base.sorcery_config.class_eval do # last login attribute name. attr_accessor :last_login_at_attribute_name # last logout attribute name. attr_accessor :last_logout_at_attribute_name # last activity attribute name. attr_accessor :last_activity_at_attribute_name # last activity login source attr_accessor :last_login_from_ip_address_name # how long since last activity is the user defined offline attr_accessor :activity_timeout end base.sorcery_config.instance_eval do @defaults.merge!(:@last_login_at_attribute_name => :last_login_at, :@last_logout_at_attribute_name => :last_logout_at, :@last_activity_at_attribute_name => :last_activity_at, :@last_login_from_ip_address_name => :last_login_from_ip_address, :@activity_timeout => 10 * 60) reset! end base.sorcery_config.after_config << :define_activity_logging_fields end