We've encountered an issue related to two-factor authentication cookie validation after a major Django version upgrade, as detailed in issue [#686](https://github.com/jazzband/django-two-factor-auth/issues/686). This issue arises due to the change in user password hashes when Django's hash iteration count is updated in a new version, leading to a mismatch in the two-factor authentication cookies' validation.

We can for now implement a workaround. This involves catching the `BadSignature` exception raised during the cookie validation process when there's a mismatch in the hashes. This situation occurs after upgrading Django, which causes the user's password hash to change, thereby invalidating the existing two-factor authentication cookies.

This issue is critical for us to upgrade our Django version without disrupting the user experience of people coming back and having a 2FA cookie.

posthog/api/authentication.py
queryset = User.objects.none()
    serializer_class = LoginSerializer
    permission_classes = (permissions.AllowAny,)
class TwoFactorSerializer(serializers.Serializer):
    token = serializers.CharField(write_only=True)
class TwoFactorViewSet(NonCreatingViewSetMixin, viewsets.GenericViewSet):
    serializer_class = TwoFactorSerializer
    queryset = User.objects.none()
    permission_classes = (permissions.AllowAny,)
    def _token_is_valid(self, request, user: User, device) -> Response:
        login(request, user, backend="django.contrib.auth.backends.ModelBackend")
        otp_login(request, device)
        report_user_logged_in(user, social_provider="")
        device.throttle_reset()
        cookie_key = REMEMBER_COOKIE_PREFIX + str(uuid4())
        cookie_value = get_remember_device_cookie(user=user, otp_device_id=device.persistent_id)
        response = Response({"success": True})
        response.set_cookie(
            cookie_key,
            cookie_value,
            max_age=settings.TWO_FACTOR_REMEMBER_COOKIE_AGE,
            domain=getattr(settings, "TWO_FACTOR_REMEMBER_COOKIE_DOMAIN", None),
            path=getattr(settings, "TWO_FACTOR_REMEMBER_COOKIE_PATH", "/"),
            secure=getattr(settings, "TWO_FACTOR_REMEMBER_COOKIE_SECURE", True),
            httponly=getattr(settings, "TWO_FACTOR_REMEMBER_COOKIE_HTTPONLY", True),
            samesite=getattr(settings, "TWO_FACTOR_REMEMBER_COOKIE_SAMESITE", "Strict"),
        )
        return response
    def create(self, request: Request, *args: Any, **kwargs: Any) -> Any: