mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
Previous cleanups (mostly the removals of Python __future__ imports) were done in a way that introduced leading newlines. Delete leading newlines from all files, except static/assets/zulip-emoji/NOTICE, which is a verbatim copy of the Apache 2.0 license. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
20 lines
617 B
Python
20 lines
617 B
Python
from django.conf import settings
|
|
|
|
import hashlib
|
|
import base64
|
|
|
|
from typing import Optional
|
|
|
|
|
|
def initial_password(email: str) -> Optional[str]:
|
|
"""Given an email address, returns the initial password for that account, as
|
|
created by populate_db."""
|
|
|
|
if settings.INITIAL_PASSWORD_SALT is not None:
|
|
encoded_key = (settings.INITIAL_PASSWORD_SALT + email).encode("utf-8")
|
|
digest = hashlib.sha256(encoded_key).digest()
|
|
return base64.b64encode(digest)[:16].decode('utf-8')
|
|
else:
|
|
# None as a password for a user tells Django to set an unusable password
|
|
return None
|