X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/fc0a6a8d7ea15bcdb27ebdd58721401c7045c6e0..18e855dc667a8cc547c687bb6e4341e84292202b:/app/models/token.rb?ds=inline diff --git a/app/models/token.rb b/app/models/token.rb old mode 100755 new mode 100644 index 2bab513..2a43630 --- a/app/models/token.rb +++ b/app/models/token.rb @@ -1,11 +1,19 @@ -class Token < ActiveRecord::Base - belongs_to :vote +# 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 + def initialize super token_generator = UniqueTokenGenerator.new( 16 ) - until not token.empty? and Token.find_all( [ "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