Module: Clearance::Model::ProtectedInstanceMethods

Defined in:
lib/clearance/app/models/model.rb

Instance Method Summary collapse

Instance Method Details

#encrypt_passwordObject



67
68
69
70
# File 'lib/clearance/app/models/model.rb', line 67

def encrypt_password
  return if password.blank?
  self.crypted_password = encrypt(password)
end

#initialize_saltObject



63
64
65
# File 'lib/clearance/app/models/model.rb', line 63

def initialize_salt
  self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{email}--") if new_record?
end

#password_required?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/clearance/app/models/model.rb', line 72

def password_required?
  crypted_password.blank? || !password.blank?
end