Module: Authlogic::ActsAsAuthentic::PersistenceToken::Methods

Defined in:
lib/authlogic/acts_as_authentic/persistence_token.rb

Overview

Methods for the persistence token.

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/authlogic/acts_as_authentic/persistence_token.rb', line 14

def self.included(klass)
  klass.class_eval do
    extend ClassMethods
    include InstanceMethods
    
    if respond_to?(:after_password_set) && respond_to?(:after_password_verification)
      after_password_set :reset_persistence_token
      after_password_verification :reset_persistence_token!, :if => :reset_persistence_token?
    end
    
    validates_presence_of :persistence_token
    validates_uniqueness_of :persistence_token, :if => :persistence_token_changed?
    
    before_validation :reset_persistence_token, :if => :reset_persistence_token?
  end
end