Module: WizAuthc::AuthcRealm::InstanceMethods

Defined in:
lib/wizdog/authc/realm/authc_realm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



31
32
33
# File 'lib/wizdog/authc/realm/authc_realm.rb', line 31

def password
  @password
end

#password_confirmationObject

Returns the value of attribute password_confirmation.



31
32
33
# File 'lib/wizdog/authc/realm/authc_realm.rb', line 31

def password_confirmation
  @password_confirmation
end

Instance Method Details

#authenticate(credential = nil) ⇒ Object



33
34
35
# File 'lib/wizdog/authc/realm/authc_realm.rb', line 33

def authenticate(credential = nil)
  self.credential == encrypt(credential)
end

#encrypt(password) ⇒ Object

Encrypts the password with the user salt



38
39
40
# File 'lib/wizdog/authc/realm/authc_realm.rb', line 38

def encrypt(password)
  Digest::SHA1.hexdigest("--#{salt}--#{password}--")
end

#encrypt_passwordObject



42
43
44
45
46
# File 'lib/wizdog/authc/realm/authc_realm.rb', line 42

def encrypt_password
  self.password = '123456' if password.blank?
  self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{}--") if new_record?
  self.crypted_password = encrypt(password)
end