mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
utils: Remove make_safe_digest wrapper.
It’s unclear what was supposed to be “safe” about this wrapper. The hashlib API is fine without it, and we don’t want to encourage further use of SHA-1. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
143baa4243
commit
052984bc14
@@ -61,12 +61,12 @@ framework; as you can see, it's very little code on top of our
|
||||
|
||||
```python
|
||||
def user_profile_cache_key_id(email: str, realm_id: int) -> str:
|
||||
return u"user_profile:%s:%s" % (make_safe_digest(email.strip()), realm_id,)
|
||||
return f"user_profile:{hashlib.sha1(email.strip().encode()).hexdigest()}:{realm_id}"
|
||||
|
||||
def user_profile_cache_key(email: str, realm: 'Realm') -> str:
|
||||
def user_profile_cache_key(email: str, realm: "Realm") -> str:
|
||||
return user_profile_cache_key_id(email, realm.id)
|
||||
|
||||
@cache_with_key(user_profile_cache_key, timeout=3600*24*7)
|
||||
@cache_with_key(user_profile_cache_key, timeout=3600 * 24 * 7)
|
||||
def get_user(email: str, realm: Realm) -> UserProfile:
|
||||
return UserProfile.objects.select_related().get(
|
||||
email__iexact=email.strip(), realm=realm)
|
||||
|
||||
Reference in New Issue
Block a user