mirror of https://github.com/zulip/zulip.git
context_processors.py: Add flag for whether user is logged in.
This commit is contained in:
parent
182570d5f3
commit
a533ab5881
|
@ -85,6 +85,10 @@ def zulip_default_context(request):
|
|||
if settings.ZILENCER_ENABLED:
|
||||
apps_page_url = '/apps/'
|
||||
|
||||
user_is_authenticated = False
|
||||
if hasattr(request, 'user') and hasattr(request.user, 'is_authenticated'):
|
||||
user_is_authenticated = request.user.is_authenticated.value
|
||||
|
||||
return {
|
||||
'realms_have_subdomains': settings.REALMS_HAVE_SUBDOMAINS,
|
||||
'custom_logo_url': settings.CUSTOM_LOGO_URL,
|
||||
|
@ -121,6 +125,7 @@ def zulip_default_context(request):
|
|||
'password_min_length': settings.PASSWORD_MIN_LENGTH,
|
||||
'password_min_quality': settings.PASSWORD_MIN_ZXCVBN_QUALITY,
|
||||
'zulip_version': ZULIP_VERSION,
|
||||
'user_is_authenticated': user_is_authenticated,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -277,13 +277,14 @@ class HostRequestMock(object):
|
|||
"""A mock request object where get_host() works. Useful for testing
|
||||
routes that use Zulip's subdomains feature"""
|
||||
|
||||
def __init__(self, host=settings.EXTERNAL_HOST):
|
||||
# type: (Text) -> None
|
||||
def __init__(self, user_profile=None, host=settings.EXTERNAL_HOST):
|
||||
# type: (UserProfile, Text) -> None
|
||||
self.host = host
|
||||
self.GET = {} # type: Dict[str, Any]
|
||||
self.POST = {} # type: Dict[str, Any]
|
||||
self.META = {'PATH_INFO': 'test'}
|
||||
self.path = ''
|
||||
self.user = user_profile
|
||||
|
||||
def get_host(self):
|
||||
# type: () -> Text
|
||||
|
|
Loading…
Reference in New Issue