mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
django commit 596564e80808 stores the user id in the session as a string, which broke our code that extracts the user id and compares it to the id of a UserProfile object. (imported from commit 99defd7fea96553550fa19e0b2f3e91a1baac123)
14 lines
414 B
Python
14 lines
414 B
Python
from __future__ import absolute_import
|
|
|
|
from django.contrib.auth import SESSION_KEY, get_user_model
|
|
|
|
def get_session_dict_user(session_dict):
|
|
# Compare django.contrib.auth._get_user_session_key
|
|
try:
|
|
return get_user_model()._meta.pk.to_python(session_dict[SESSION_KEY])
|
|
except KeyError:
|
|
return None
|
|
|
|
def get_session_user(session):
|
|
return get_session_dict_user(session.get_decoded())
|