zerver/lib/initial_password.py: Encode return value.

zerver.lib.initial_password.initial_password is supposed to return an
Optional[text_type], but it returns an Optional[binary_type] instead.
Encode the return value to make sure it returns an Optional[text_type].
This commit is contained in:
Eklavya Sharma 2016-06-17 20:33:09 +05:30 committed by Tim Abbott
parent 018041625c
commit 6097f6eed5
1 changed files with 1 additions and 1 deletions

View File

@ -17,7 +17,7 @@ def initial_password(email):
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]
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