Guest User

Untitled

a guest
May 25th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. require 'bcrypt'
  2.  
  3. module Gencore
  4. class User < Sequel::Model
  5. set_schema do
  6. primary_key :id
  7. varchar :username
  8. text :passwd, :default => '*'
  9. end
  10.  
  11. one_to_one :biodata, :class => 'Gencore::Biodata'
  12. one_to_many :ftp_logs, :class => 'Gencore::Ftp_log'
  13.  
  14. include BCrypt
  15.  
  16. def password
  17. @password ||= Password.new(passwd)
  18. end
  19.  
  20. def password=(new_password)
  21. @password = Password.create(new_password)
  22. self.passwd = @password
  23. end
  24.  
  25. create_table unless table_exists?
  26.  
  27. ##### test case, TODO move this to spec file
  28. if empty?
  29. user = create(:username => 'fudanchii',
  30. :password => 'testest')
  31. puts user.password
  32. puts user.password == 'testest'
  33. end
  34.  
  35. end
  36. end
Add Comment
Please, Sign In to add comment