'Checks to make sure the user is logged in & has a Django session.'

def is_authenticated(self, request, **kwargs):

    if (request.method in (u'GET', u'HEAD', u'OPTIONS', u'TRACE')):
        return is_authenticated(request.user)
    if getattr(request, u'_dont_enforce_csrf_checks', False):
        return is_authenticated(request.user)
    csrf_token = _sanitize_token(request.COOKIES.get(settings.CSRF_COOKIE_NAME, u''))
    if request.is_secure():
        referer = request.META.get(u'HTTP_REFERER')
        if (referer is None):
            return False
        good_referer = (u'https://%s/' % request.get_host())
        if (not same_origin(referer, good_referer)):
            return False
    request_csrf_token = request.META.get(u'HTTP_X_CSRFTOKEN', u'')
    request_csrf_token = _sanitize_token(request_csrf_token)
    if (not constant_time_compare(unsalt_token(request_csrf_token), unsalt_token(csrf_token))):
        return False
    return is_authenticated(request.user)
