diff --git a/helios/models.py b/helios/models.py index 8f92737e4fc436d209c5837547c58797a114faa0..b1ce74d13e76d1dbe46d07edd5d020855b856302 100644 --- a/helios/models.py +++ b/helios/models.py @@ -925,7 +925,7 @@ class Voter(HeliosModel): if self.voter_password: raise Exception("password already exists") - self.voter_password = heliosutils.random_string(length) + self.voter_password = heliosutils.random_string(length, alphabet='abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ23456789') def store_vote(self, cast_vote): # only store the vote if it's cast later than the current one diff --git a/helios/utils.py b/helios/utils.py index 5bb805ba55307cc7aacf0928d8fcd9e05b7b1432..2db3dd772f27c9cc378688cbf629b3472cd6ea78 100644 --- a/helios/utils.py +++ b/helios/utils.py @@ -119,9 +119,9 @@ def xss_strip_all_tags(s): random.seed() -def random_string(length=20): +def random_string(length=20, alphabet=None): random.seed() - ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' + ALPHABET = alphabet or 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' r_string = '' for i in range(length): r_string += random.choice(ALPHABET)