From 3cbc56a866c9f193cc84ca009ca5d02738bf3ab3 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Fri, 21 Sep 2012 11:08:02 -0400 Subject: [PATCH] Rename MD5_SALT to HASH_SALT (imported from commit 3112cd805614c3057a9eb8f1b251381f48ab3173) --- humbug/settings.py | 4 +++- zephyr/models.py | 4 ++-- zephyr/views.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/humbug/settings.py b/humbug/settings.py index 329f31ae6b..0b9a0879bc 100644 --- a/humbug/settings.py +++ b/humbug/settings.py @@ -97,7 +97,9 @@ STATICFILES_FINDERS = ( # Make this unique, and don't share it with anybody. SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' -MD5_SALT = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' +# A fixed salt used for hashing in certain places, e.g. email-based +# username generation. +HASH_SALT = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( diff --git a/zephyr/models.py b/zephyr/models.py index bc1c362081..9b36a75939 100644 --- a/zephyr/models.py +++ b/zephyr/models.py @@ -87,7 +87,7 @@ class UserProfile(models.Model): Subscription(userprofile=profile, recipient=recipient).save() def create_user(email, password, realm, full_name, short_name): - username = hashlib.md5(settings.MD5_SALT + email).hexdigest() + username = hashlib.md5(settings.HASH_SALT + email).hexdigest() user = User.objects.create_user(username=username, password=password, email=email) user.save() @@ -156,7 +156,7 @@ class Zephyr(models.Model): 'instance' : self.instance, 'content' : self.content, 'timestamp' : calendar.timegm(self.pub_date.timetuple()), - 'gravatar_hash' : hashlib.md5(settings.MD5_SALT + self.sender.user.email).hexdigest(), + 'gravatar_hash' : hashlib.md5(settings.HASH_SALT + self.sender.user.email).hexdigest(), } class UserMessage(models.Model): diff --git a/zephyr/views.py b/zephyr/views.py index f5c8f0c217..e1939431de 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -113,7 +113,7 @@ def home(request): return render_to_response('zephyr/index.html', {'zephyr_array' : zephyr_json, 'user_profile': user_profile, - 'email_hash' : hashlib.md5(settings.MD5_SALT + user_profile.user.email).hexdigest(), + 'email_hash' : hashlib.md5(settings.HASH_SALT + user_profile.user.email).hexdigest(), 'people' : simplejson.dumps(people), 'classes' : simplejson.dumps(classes), 'instances' : simplejson.dumps(instances)},