Sha256: b777ebdaa527e9653c5d3c76be433c0324d3b1c415a97022c91836cbf62f2d2b

Contents?: true

Size: 1010 Bytes

Versions: 3

Compression:

Stored size: 1010 Bytes

Contents

module Authlogic
  module Session
    # = Session
    #
    # Handles all parts of authentication that deal with sessions. Such as persisting a session and saving / destroy a session.
    module Session
      def self.included(klass)
        klass.after_save :update_session!, :if => :persisting?
        klass.after_destroy :update_session!, :if => :persisting?
        klass.after_find :update_session!, :if => :persisting?
      end
      
      # Tries to validate the session from information in the session
      def valid_session?
        if session_credentials
          self.unauthorized_record = search_for_record("find_by_#{remember_token_field}", session_credentials)
          return valid?
        end
        
        false
      end
      
      private
        def session_credentials
          controller.session[session_key]
        end
        
        def update_session!
          controller.session[session_key] = record && record.send(remember_token_field)
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
authlogic-1.1.1 lib/authlogic/session/session.rb
authlogic-1.1.2 lib/authlogic/session/session.rb
authlogic-1.2.0 lib/authlogic/session/session.rb