Sha256: b4ff18a68434bc528a84d907b6eb9ddf72a0dbf8904591cdc127bd3bbe558392

Contents?: true

Size: 1016 Bytes

Versions: 1

Compression:

Stored size: 1016 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_#{persistence_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(persistence_token_field)
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authlogic-1.2.1 lib/authlogic/session/session.rb