Module: Cms::Authentication::Model

Included in:
User
Defined in:
lib/cms/authentication/model.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(model_class) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/cms/authentication/model.rb', line 4

def self.included(model_class)
  model_class.extend ClassMethods
  model_class.class_eval do
    include InstanceMethods
  
    # 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