'To be called when user authentication fails when processing
requests in the middleware. Sets a flag to delete the user\'s
cookie and redirects the user to the login page.'

@staticmethod
def _on_user_authentication_failed(request):

    _mark_cookie_for_deletion(request)
    if is_request_from_mobile_app(request):
        return HttpResponse(status=401)
    return redirect_to_login(request.path)
