X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/8f23a174c70223831055e1498b50c3ba260858fe..3062c2d0a2b51fdf3c6b1f3bbd35d524020890a7:/app/models/token.rb?ds=sidebyside diff --git a/app/models/token.rb b/app/models/token.rb index e9f4fd6..2a43630 100644 --- a/app/models/token.rb +++ b/app/models/token.rb @@ -1,3 +1,10 @@ +# Selectricity: Voting Machinery for the Masses +# Copyright (C) 2007, 2008 Benjamin Mako Hill +# Copyright (C) 2007 Massachusetts Institute of Technology +# +# This program is free software. Please see the COPYING file for +# details. + class Token < ActiveRecord::Base belongs_to :vote @@ -5,7 +12,8 @@ class Token < ActiveRecord::Base super token_generator = UniqueTokenGenerator.new( 16 ) - until not token.empty? and Token.find(:all, :conditions => [ "token = ?", token ]).empty? + until token and not token.empty? \ + and Token.find(:all, :conditions => [ "token = ?", token ]).empty? and token[0..3] != "open" self.token = token_generator.token end