Module: Sorcery::Model::Adapters::ActiveRecord::ClassMethods
- Defined in:
- lib/sorcery/model/adapters/active_record.rb
Instance Method Summary collapse
- #find_by_credentials(credentials) ⇒ Object
- #find_by_sorcery_token(token_attr_name, token) ⇒ Object
- #get_current_users ⇒ Object
Instance Method Details
#find_by_credentials(credentials) ⇒ Object
10 11 12 13 |
# File 'lib/sorcery/model/adapters/active_record.rb', line 10 def find_by_credentials(credentials) sql = @sorcery_config.username_attribute_names.map{|attribute| "#{attribute} = :login"} where(sql.join(' OR '), :login => credentials[0]).first end |
#find_by_sorcery_token(token_attr_name, token) ⇒ Object
15 16 17 |
# File 'lib/sorcery/model/adapters/active_record.rb', line 15 def find_by_sorcery_token(token_attr_name, token) where("#{token_attr_name} = ?", token).first end |
#get_current_users ⇒ Object
19 20 21 22 23 24 |
# File 'lib/sorcery/model/adapters/active_record.rb', line 19 def get_current_users config = sorcery_config where("#{config.last_activity_at_attribute_name} IS NOT NULL") \ .where("#{config.last_logout_at_attribute_name} IS NULL OR #{config.last_activity_at_attribute_name} > #{config.last_logout_at_attribute_name}") \ .where("#{config.last_activity_at_attribute_name} > ? ", config.activity_timeout.seconds.ago.utc.to_s(:db)) end |