Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix: domain links should work the same
Marc Seitzaaa3e14337d6
diff --git a/pages/view/domains/[domain]/[slug]/index.tsx b/pages/view/domains/[domain]/[slug]/index.tsxindex 4c19fbe4..7f51598f 100644--- a/pages/view/domains/[domain]/[slug]/index.tsx+++ b/pages/view/domains/[domain]/[slug]/index.tsx@@ -2,21 +2,38 @@ import LoadingSpinner from "@/components/ui/loading-spinner";import DocumentView from "@/components/view/document-view";import { useDomainLink } from "@/lib/swr/use-link";import NotFound from "@/pages/404";+import { useSession } from "next-auth/react";export default function ViewPage() {const { link, error } = useDomainLink();+ const { data: session, status } = useSession();if (error && error.status === 404) {return <NotFound />;}-- if (!link) {++ if (!link || status === "loading") {return (<div className="h-screen flex items-center justify-center">- <LoadingSpinner className="mr-1 h-20 w-20" />+ <LoadingSpinner className="h-20 w-20" /></div>);}- return <DocumentView link={link} error={error} />;+ const { expiresAt, emailProtected, password: linkPassword } = link;++ const { email: userEmail } = session?.user || {};++ // If the link is expired, show a 404 page+ if (expiresAt && new Date(expiresAt) < new Date()) {+ return <NotFound />;+ }++ if (emailProtected || linkPassword) {+ return (+ <DocumentView link={link} userEmail={userEmail} isProtected={true} />+ );+ }++ return <DocumentView link={link} userEmail={userEmail} isProtected={false} />;}