def METHOD_NAME(self, request, user, **kwargs):
    # this is copied from the a pending PR on django-allauth-2fa repo:
    # https://github.com/valohai/django-allauth-2fa/pull/131
    response = super().METHOD_NAME(request, user, **kwargs)
    if response:
        return response
    # Require two-factor authentication if it has been configured
    if self.has_2fa_enabled(user):
        self.stash_pending_login(request, user, **kwargs)
        redirect_url = reverse("two-factor-authenticate")
        query_params = request.GET.copy()
        next_url = get_next_redirect_url(request)
        if next_url:
            query_params["next"] = next_url
        if query_params:
            redirect_url += "?" + urlencode(query_params)
        raise ImmediateHttpResponse(
            response=HttpResponseRedirect(redirect_url)
        )