Advertisement
Guest User

Untitled

a guest
Jan 28th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. include BCrypt
  2.  
  3. #requires username column on Users table
  4. def self.authenticate(username, password)
  5. user = User.find_by(username: username)
  6. if user
  7. return user if user.password == password
  8. end
  9. end
  10.  
  11. def password
  12. @password ||= Password.new(password_hash)
  13. end
  14.  
  15. #requires password_hash column on Users table
  16. def password=(new_password)
  17. @password = Password.create(new_password)
  18. self.password_hash = @password
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement