+ def self.authenticate(email, passwd)
+ find_first([ "email = ? AND pass_crypt =?", email, Digest::MD5.hexdigest(passwd) ])
+ end
+
+ def self.authenticate_token(token)
+ find_first([ "token = ? ", token])
+ end
+
+ def self.make_token(length=30)
+ chars = 'abcdefghijklmnopqrtuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
+ confirmstring = ''
+
+ length.times do
+ confirmstring += chars[(rand * chars.length).to_i].chr
+ end
+
+ return confirmstring
+ end