#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
import { useEffect, useState, type ReactNode } from "react";
import { useAuth } from "@editor/auth";
import { bindAccountLinkSession } from "@editor/portal/auth/accountLinkSession";
/** Prevents attended queries and callbacks from running under a previous local user's session. */
export function AccountLinkSessionBoundary({
children,
}: {
children: ReactNode;
}) {
const { user, isAdmin, loading } = useAuth();
const identity = isAdmin && user?.orgOwner === true ? user.id : null;
const [bound, setBound] = useState<string | null>();
useEffect(() => {
if (loading) return;
bindAccountLinkSession(identity);
setBound(identity);
}, [identity, loading]);
if (loading || identity !== bound) return null;
return children;
}