2013-04-23 18:51:17 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2012-10-10 16:59:59 +02:00
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
import hashlib
|
|
|
|
import base64
|
|
|
|
|
|
|
|
def initial_password(email):
|
|
|
|
"""Given an email address, returns the initial password for that account, as
|
|
|
|
created by populate_db."""
|
|
|
|
|
2013-11-12 18:20:05 +01:00
|
|
|
if settings.INITIAL_PASSWORD_SALT is not None:
|
|
|
|
digest = hashlib.sha256(settings.INITIAL_PASSWORD_SALT + email).digest()
|
|
|
|
return base64.b64encode(digest)[:16]
|
|
|
|
else:
|
|
|
|
# None as a password for a user tells Django to set an unusable password
|
|
|
|
return None
|