diff --git a/zerver/context_processors.py b/zerver/context_processors.py index 8402769601..f2163c3682 100644 --- a/zerver/context_processors.py +++ b/zerver/context_processors.py @@ -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, } diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py index 8eb4248035..8fcaf8467d 100644 --- a/zerver/lib/test_helpers.py +++ b/zerver/lib/test_helpers.py @@ -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