Commits

fcoelho  committed ba4df75

fixes to validation hash generation and management command

  • Participants
  • Parent commits 8db6bea
  • Tags 0.2.1

Comments (0)

Files changed (3)

File docs/installation.rst

 
 To install ``django-signup``, use pip:
 
-.. code:: sh
+.. code-block:: sh
 
     pip install django-signup
 
 If you want the latest-and-greatest version, install it with
 
-.. code:: sh
+.. code-block:: sh
 
     pip install -e  hg+http://bitbucket.org/fcoelho/django-signup#egg=django-signup
 

File signup/management/commands/clear_expired_signups.py

 
 		limit_time = now() - timedelta(days=activation_days)
 
-		expired = Validation.objects.filter(created_lt=limit_time)
+		expired = Validation.objects.filter(created__lt=limit_time)
 		for validation in expired:
 			user = validation.user
 			# cascade takes care of deleting validation

File signup/models.py

 		v = Validation(user=user)
 
 		salt = hashlib.sha256(str(random.random())).hexdigest()
-		key = hashlib.sha256(salt + user.get_full_name()).hexdigest()
+		# we encode it to utf-8 and ignore any stray input to be able to
+		# hash the string
+		to_hash = (salt + user.get_full_name()).encode('utf-8', 'ignore')
+		key = hashlib.sha256(to_hash).hexdigest()
 
 		v.key = key
 		v.save(using=self._db)