Module: Sinatra::SimpleAuthentication::Models::Common::InstanceMethods
- Defined in:
- lib/sinatra/simple_authentication/models/common/instance_methods.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
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/sinatra/simple_authentication/models/common/instance_methods.rb', line 8 def password @password end |
#password_confirmation ⇒ Object
Returns the value of attribute password_confirmation.
8 9 10 |
# File 'lib/sinatra/simple_authentication/models/common/instance_methods.rb', line 8 def password_confirmation @password_confirmation end |
Instance Method Details
#authenticate(pass) ⇒ Object
26 27 28 |
# File 'lib/sinatra/simple_authentication/models/common/instance_methods.rb', line 26 def authenticate(pass) encrypt(pass, self.salt) == self.hashed_password end |
#encrypt(password, salt) ⇒ Object
22 23 24 |
# File 'lib/sinatra/simple_authentication/models/common/instance_methods.rb', line 22 def encrypt(password, salt) Digest::SHA1.hexdigest(password + salt) end |
#generate_salt ⇒ Object
18 19 20 |
# File 'lib/sinatra/simple_authentication/models/common/instance_methods.rb', line 18 def generate_salt (0..25).inject('') { |r, i| r << rand(93) + 33 } end |