Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'bcrypt'
- module Gencore
- class User < Sequel::Model
- set_schema do
- primary_key :id
- varchar :username
- text :passwd, :default => '*'
- end
- one_to_one :biodata, :class => 'Gencore::Biodata'
- one_to_many :ftp_logs, :class => 'Gencore::Ftp_log'
- include BCrypt
- def password
- @password ||= Password.new(passwd)
- end
- def password=(new_password)
- @password = Password.create(new_password)
- self.passwd = @password
- end
- create_table unless table_exists?
- ##### test case, TODO move this to spec file
- if empty?
- user = create(:username => 'fudanchii',
- :password => 'testest')
- puts user.password
- puts user.password == 'testest'
- end
- end
- end
Add Comment
Please, Sign In to add comment