mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 12:03:46 +00:00 
			
		
		
		
	Fixes #2665. Regenerated by tabbott with `lint --fix` after a rebase and change in parameters. Note from tabbott: In a few cases, this converts technical debt in the form of unsorted imports into different technical debt in the form of our largest files having very long, ugly import sequences at the start. I expect this change will increase pressure for us to split those files, which isn't a bad thing. Signed-off-by: Anders Kaseorg <anders@zulip.com>
		
			
				
	
	
		
			19 lines
		
	
	
		
			616 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
		
			616 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import base64
 | |
| import hashlib
 | |
| from typing import Optional
 | |
| 
 | |
| from django.conf import settings
 | |
| 
 | |
| 
 | |
| 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
 |