Guest User

Untitled

a guest
Jan 23rd, 2018
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. def self.authenticate(email, password)
  2. user = find_by_email(email)
  3. if user
  4. if user.encrypted_password == Digest::SHA1.hexdigest(password) # This is for backwards-compatibility because I changed the encryption method.
  5. user.encrypt_password # It can be removed once all user records have encrypted_password = NULL
  6. user.update_attribute('encrypted_password', nil)
  7. user
  8. elsif user.password_hash == BCrypt::Engine.hash_secret(password, user.password_salt)
  9. user
  10. end
  11. else
  12. nil
  13. end
  14. end
Add Comment
Please, Sign In to add comment