Module: WizAuthc::AuthcRealm::InstanceMethods
- Defined in:
- lib/wizdog/authc/realm/authc_realm.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#password_confirmation ⇒ Object
Returns the value of attribute password_confirmation.
Instance Method Summary collapse
- #authenticate(credential = nil) ⇒ Object
-
#encrypt(password) ⇒ Object
Encrypts the password with the user salt.
- #encrypt_password ⇒ Object
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
31 32 33 |
# File 'lib/wizdog/authc/realm/authc_realm.rb', line 31 def password @password end |
#password_confirmation ⇒ Object
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_password ⇒ Object
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}--#{login}--") if new_record? self.crypted_password = encrypt(password) end |