Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'digest/sha1'
- class User < ActiveRecord::Base
- validates_presence_of :username, :password
- def self.authenticate(username, password)
- if password
- sha1password = Digest::SHA1.hexdigest(password)
- else
- sha1password = ''
- end
- return find(:first, :conditions => [ "username = '#{username}' AND password = '#{sha1password}'" ])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement