Module: Authentication::ByPassword

Included in:
User
Defined in:
lib/branston/vendor/plugins/restful_authentication/lib/authentication/by_password.rb

Defined Under Namespace

Modules: ModelClassMethods, ModelInstanceMethods

Class Method Summary collapse

Class Method Details

.included(recipient) ⇒ Object

Stuff directives into including module



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/branston/vendor/plugins/restful_authentication/lib/authentication/by_password.rb', line 4

def self.included(recipient)
  recipient.extend(ModelClassMethods)
  recipient.class_eval do
    include ModelInstanceMethods
    
    # Virtual attribute for the unencrypted password
    attr_accessor :password
    validates_presence_of     :password,                   :if => :password_required?
    validates_presence_of     :password_confirmation,      :if => :password_required?
    validates_confirmation_of :password,                   :if => :password_required?
    validates_length_of       :password, :within => 6..40, :if => :password_required?
    before_save :encrypt_password
  end
end