Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: allow preview session to be auto-logged in

Marc Seitz32bfeb9d9051
diff --git a/app/api/views-dataroom/route.ts b/app/api/views-dataroom/route.ts
index 8d3d50b3..1dc4698c 100644
--- a/app/api/views-dataroom/route.ts
+++ b/app/api/views-dataroom/route.ts
@@ -145,11 +145,33 @@ export async function POST(request: NextRequest) {
);
}
- // Check if there's a valid preview session
- let previewSession: PreviewSession | null = null;
+ let isEmailVerified: boolean = false;
+ let hashedVerificationToken: string | null = null;
+ // Check if the user is part of the team and therefore skip verification steps
+ let isTeamMember: boolean = false;
let isPreview: boolean = false;
+ if (userId && previewToken) {
+ const session = await getServerSession(authOptions);
+ if (!session) {
+ return NextResponse.json(
+ { message: "You need to be logged in to preview the link." },
+ { status: 401 },
+ );
+ }
+
+ const teamMembership = await prisma.userTeam.findUnique({
+ where: { userId_teamId: { userId: userId, teamId: link.teamId! } },
+ });
+ if (teamMembership) {
+ isTeamMember = true;
+ isPreview = true;
+ isEmailVerified = true;
+ }
+ }
- if (previewToken) {
+ // Check if there's a valid preview session
+ let previewSession: PreviewSession | null = null;
+ if (!isPreview && previewToken) {
const session = await getServerSession(authOptions);
if (!session) {
return NextResponse.json(
@@ -185,8 +207,6 @@ export async function POST(request: NextRequest) {
);
}
- let isEmailVerified: boolean = false;
- let hashedVerificationToken: string | null = null;
// If there is no session, then we need to check if the link is protected and enforce the checks
if (!dataroomSession && !isPreview) {
// Check if email is required for visiting the link
@@ -625,6 +645,7 @@ export async function POST(request: NextRequest) {
viewerId: viewer?.id,
conversationsEnabled: link.enableConversation,
enableVisitorUpload: link.enableUpload,
+ isTeamMember: isTeamMember ? true : undefined,
};
const response = NextResponse.json(returnObject, { status: 200 });
@@ -910,6 +931,7 @@ export async function POST(request: NextRequest) {
canDownload: canDownload,
viewerId: viewer?.id,
conversationsEnabled: link.enableConversation,
+ isTeamMember: isTeamMember ? true : undefined,
};
const response = NextResponse.json(returnObject, { status: 200 });
diff --git a/app/api/views/route.ts b/app/api/views/route.ts
index a745cac8..8132138c 100644
--- a/app/api/views/route.ts
+++ b/app/api/views/route.ts
@@ -110,10 +110,12 @@ export async function POST(request: NextRequest) {
},
});
+ // Check if link exists
if (!link) {
return NextResponse.json({ message: "Link not found." }, { status: 404 });
}
+ // Check if link is archived
if (link.isArchived) {
return NextResponse.json(
{ message: "Link is no longer available." },
@@ -121,267 +123,293 @@ export async function POST(request: NextRequest) {
);
}
- // Check if email is required for visiting the link
- if (link.emailProtected) {
- if (!email || email.trim() === "") {
+ let isEmailVerified: boolean = false;
+ let hashedVerificationToken: string | null = null;
+ // Check if the user is part of the team and therefore skip verification steps
+ let isTeamMember: boolean = false;
+ let isPreview: boolean = false;
+ if (userId && previewToken) {
+ const session = await getServerSession(authOptions);
+ if (!session) {
return NextResponse.json(
- { message: "Email is required." },
- { status: 400 },
+ { message: "You need to be logged in to preview the link." },
+ { status: 401 },
);
}
- // validate email
- if (!validateEmail(email)) {
- return NextResponse.json(
- { message: "Invalid email address." },
- { status: 400 },
- );
+ const teamMembership = await prisma.userTeam.findUnique({
+ where: { userId_teamId: { userId: userId, teamId: link.teamId! } },
+ });
+ if (teamMembership) {
+ isTeamMember = true;
+ isPreview = true;
+ isEmailVerified = true;
}
}
- // Check if password is required for visiting the link
- if (link.password) {
- if (!password || password.trim() === "") {
- return NextResponse.json(
- { message: "Password is required." },
- { status: 400 },
- );
+ if (!isTeamMember) {
+ // Check if email is required for visiting the link
+ if (link.emailProtected) {
+ if (!email || email.trim() === "") {
+ return NextResponse.json(
+ { message: "Email is required." },
+ { status: 400 },
+ );
+ }
+
+ // validate email
+ if (!validateEmail(email)) {
+ return NextResponse.json(
+ { message: "Invalid email address." },
+ { status: 400 },
+ );
+ }
}
- let isPasswordValid: boolean = false;
- const textParts: string[] = link.password.split(":");
- if (!textParts || textParts.length !== 2) {
- isPasswordValid = await checkPassword(password, link.password);
- } else {
- const decryptedPassword = decryptEncrpytedPassword(link.password);
- isPasswordValid = decryptedPassword === password;
+ // Check if password is required for visiting the link
+ if (link.password) {
+ if (!password || password.trim() === "") {
+ return NextResponse.json(
+ { message: "Password is required." },
+ { status: 400 },
+ );
+ }
+
+ let isPasswordValid: boolean = false;
+ const textParts: string[] = link.password.split(":");
+ if (!textParts || textParts.length !== 2) {
+ isPasswordValid = await checkPassword(password, link.password);
+ } else {
+ const decryptedPassword = decryptEncrpytedPassword(link.password);
+ isPasswordValid = decryptedPassword === password;
+ }
+
+ if (!isPasswordValid) {
+ return NextResponse.json(
+ { message: "Invalid password." },
+ { status: 403 },
+ );
+ }
}
- if (!isPasswordValid) {
+ // Check if agreement is required for visiting the link
+ if (link.enableAgreement && !hasConfirmedAgreement) {
return NextResponse.json(
- { message: "Invalid password." },
- { status: 403 },
+ { message: "Agreement to NDA is required." },
+ { status: 400 },
);
}
- }
-
- // Check if agreement is required for visiting the link
- if (link.enableAgreement && !hasConfirmedAgreement) {
- return NextResponse.json(
- { message: "Agreement to NDA is required." },
- { status: 400 },
- );
- }
- // Check if email is allowed to visit the link
- if (link.allowList && link.allowList.length > 0) {
- // Extract the domain from the email address
- const emailDomain = email.substring(email.lastIndexOf("@"));
+ // Check if email is allowed to visit the link
+ if (link.allowList && link.allowList.length > 0) {
+ // Extract the domain from the email address
+ const emailDomain = email.substring(email.lastIndexOf("@"));
- // Determine if the email or its domain is allowed
- const isAllowed = link.allowList.some((allowed) => {
- return (
- allowed === email ||
- (allowed.startsWith("@") && emailDomain === allowed)
- );
- });
+ // Determine if the email or its domain is allowed
+ const isAllowed = link.allowList.some((allowed) => {
+ return (
+ allowed === email ||
+ (allowed.startsWith("@") && emailDomain === allowed)
+ );
+ });
- // Deny access if the email is not allowed
- if (!isAllowed) {
- return NextResponse.json(
- { message: "Unauthorized access" },
- { status: 403 },
- );
+ // Deny access if the email is not allowed
+ if (!isAllowed) {
+ return NextResponse.json(
+ { message: "Unauthorized access" },
+ { status: 403 },
+ );
+ }
}
- }
- // Check if email is denied to visit the link
- if (link.denyList && link.denyList.length > 0) {
- // Extract the domain from the email address
- const emailDomain = email.substring(email.lastIndexOf("@"));
+ // Check if email is denied to visit the link
+ if (link.denyList && link.denyList.length > 0) {
+ // Extract the domain from the email address
+ const emailDomain = email.substring(email.lastIndexOf("@"));
- // Determine if the email or its domain is denied
- const isDenied = link.denyList.some((denied) => {
- return (
- denied === email || (denied.startsWith("@") && emailDomain === denied)
- );
- });
+ // Determine if the email or its domain is denied
+ const isDenied = link.denyList.some((denied) => {
+ return (
+ denied === email ||
+ (denied.startsWith("@") && emailDomain === denied)
+ );
+ });
- // Deny access if the email is denied
- if (isDenied) {
- return NextResponse.json(
- { message: "Unauthorized access" },
- { status: 403 },
- );
+ // Deny access if the email is denied
+ if (isDenied) {
+ return NextResponse.json(
+ { message: "Unauthorized access" },
+ { status: 403 },
+ );
+ }
}
- }
- // Request OTP Code for email verification if
- // 1) email verification is required and
- // 2) code is not provided or token not provided
- if (link.emailAuthenticated && !code && !token) {
- const ipAddressValue = ipAddress(request);
+ // Request OTP Code for email verification if
+ // 1) email verification is required and
+ // 2) code is not provided or token not provided
+ if (link.emailAuthenticated && !code && !token) {
+ const ipAddressValue = ipAddress(request);
- const { success } = await ratelimit(10, "1 m").limit(
- `send-otp:${ipAddressValue}`,
- );
- if (!success) {
- return NextResponse.json(
- { message: "Too many requests. Please try again later." },
- { status: 429 },
+ const { success } = await ratelimit(10, "1 m").limit(
+ `send-otp:${ipAddressValue}`,
);
- }
-
- await prisma.verificationToken.deleteMany({
- where: {
- identifier: `otp:${linkId}:${email}`,
- },
- });
+ if (!success) {
+ return NextResponse.json(
+ { message: "Too many requests. Please try again later." },
+ { status: 429 },
+ );
+ }
- const otpCode = generateOTP();
- const expiresAt = new Date();
- expiresAt.setMinutes(expiresAt.getMinutes() + 10); // token expires at 10 minutes
+ await prisma.verificationToken.deleteMany({
+ where: {
+ identifier: `otp:${linkId}:${email}`,
+ },
+ });
- await prisma.verificationToken.create({
- data: {
- token: otpCode,
- identifier: `otp:${linkId}:${email}`,
- expires: expiresAt,
- },
- });
+ const otpCode = generateOTP();
+ const expiresAt = new Date();
+ expiresAt.setMinutes(expiresAt.getMinutes() + 10); // token expires at 10 minutes
- waitUntil(sendOtpVerificationEmail(email, otpCode, false, link.teamId!));
- return NextResponse.json({
- type: "email-verification",
- message: "Verification email sent.",
- });
- }
+ await prisma.verificationToken.create({
+ data: {
+ token: otpCode,
+ identifier: `otp:${linkId}:${email}`,
+ expires: expiresAt,
+ },
+ });
- let isEmailVerified: boolean = false;
- let hashedVerificationToken: string | null = null;
- if (link.emailAuthenticated && code) {
- const ipAddressValue = ipAddress(request);
- const { success } = await ratelimit(10, "1 m").limit(
- `verify-otp:${ipAddressValue}`,
- );
- if (!success) {
- return NextResponse.json(
- { message: "Too many requests. Please try again later." },
- { status: 429 },
+ waitUntil(
+ sendOtpVerificationEmail(email, otpCode, false, link.teamId!),
);
+ return NextResponse.json({
+ type: "email-verification",
+ message: "Verification email sent.",
+ });
}
- // Check if the OTP code is valid
- const verification = await prisma.verificationToken.findUnique({
- where: {
- token: code,
- identifier: `otp:${linkId}:${email}`,
- },
- });
-
- if (!verification) {
- return NextResponse.json(
- {
- message: "Unauthorized access. Request new access.",
- resetVerification: true,
- },
- { status: 401 },
+ if (link.emailAuthenticated && code) {
+ const ipAddressValue = ipAddress(request);
+ const { success } = await ratelimit(10, "1 m").limit(
+ `verify-otp:${ipAddressValue}`,
);
- }
+ if (!success) {
+ return NextResponse.json(
+ { message: "Too many requests. Please try again later." },
+ { status: 429 },
+ );
+ }
- // Check the OTP code's expiration date
- if (Date.now() > verification.expires.getTime()) {
- await prisma.verificationToken.delete({
+ // Check if the OTP code is valid
+ const verification = await prisma.verificationToken.findUnique({
where: {
token: code,
+ identifier: `otp:${linkId}:${email}`,
},
});
- return NextResponse.json(
- {
- message: "Access expired. Request new access.",
- resetVerification: true,
- },
- { status: 401 },
- );
- }
- // delete the OTP code after verification
- await prisma.verificationToken.delete({
- where: {
- token: code,
- },
- });
+ if (!verification) {
+ return NextResponse.json(
+ {
+ message: "Unauthorized access. Request new access.",
+ resetVerification: true,
+ },
+ { status: 401 },
+ );
+ }
- // Create a email verification token for repeat access
- const token = newId("email");
- hashedVerificationToken = hashToken(token);
- const tokenExpiresAt = new Date();
- tokenExpiresAt.setHours(tokenExpiresAt.getHours() + 23); // token expires at 23 hours
- await prisma.verificationToken.create({
- data: {
- token: hashedVerificationToken,
- identifier: `link-verification:${linkId}:${link.teamId}:${email}`,
- expires: tokenExpiresAt,
- },
- });
+ // Check the OTP code's expiration date
+ if (Date.now() > verification.expires.getTime()) {
+ await prisma.verificationToken.delete({
+ where: {
+ token: code,
+ },
+ });
+ return NextResponse.json(
+ {
+ message: "Access expired. Request new access.",
+ resetVerification: true,
+ },
+ { status: 401 },
+ );
+ }
- isEmailVerified = true;
- }
+ // delete the OTP code after verification
+ await prisma.verificationToken.delete({
+ where: {
+ token: code,
+ },
+ });
- if (link.emailAuthenticated && token) {
- const ipAddressValue = ipAddress(request);
- const { success } = await ratelimit(10, "1 m").limit(
- `verify-email:${ipAddressValue}`,
- );
- if (!success) {
- return NextResponse.json(
- { message: "Too many requests. Please try again later." },
- { status: 429 },
- );
- }
+ // Create a email verification token for repeat access
+ const token = newId("email");
+ hashedVerificationToken = hashToken(token);
+ const tokenExpiresAt = new Date();
+ tokenExpiresAt.setHours(tokenExpiresAt.getHours() + 23); // token expires at 23 hours
+ await prisma.verificationToken.create({
+ data: {
+ token: hashedVerificationToken,
+ identifier: `link-verification:${linkId}:${link.teamId}:${email}`,
+ expires: tokenExpiresAt,
+ },
+ });
- // Check if the long-term verification token is valid
- const verification = await prisma.verificationToken.findUnique({
- where: {
- token: token,
- identifier: `link-verification:${linkId}:${link.teamId}:${email}`,
- },
- });
+ isEmailVerified = true;
+ }
- if (!verification) {
- return NextResponse.json(
- {
- message: "Unauthorized access. Request new access.",
- resetVerification: true,
- },
- { status: 401 },
+ if (link.emailAuthenticated && token) {
+ const ipAddressValue = ipAddress(request);
+ const { success } = await ratelimit(10, "1 m").limit(
+ `verify-email:${ipAddressValue}`,
);
- }
+ if (!success) {
+ return NextResponse.json(
+ { message: "Too many requests. Please try again later." },
+ { status: 429 },
+ );
+ }
- // Check the long-term verification token's expiration date
- if (Date.now() > verification.expires.getTime()) {
- // delete the long-term verification token after verification
- await prisma.verificationToken.delete({
+ // Check if the long-term verification token is valid
+ const verification = await prisma.verificationToken.findUnique({
where: {
token: token,
+ identifier: `link-verification:${linkId}:${link.teamId}:${email}`,
},
});
- return NextResponse.json(
- {
- message: "Access expired. Request new access.",
- resetVerification: true,
- },
- { status: 401 },
- );
- }
- isEmailVerified = true;
+ if (!verification) {
+ return NextResponse.json(
+ {
+ message: "Unauthorized access. Request new access.",
+ resetVerification: true,
+ },
+ { status: 401 },
+ );
+ }
+
+ // Check the long-term verification token's expiration date
+ if (Date.now() > verification.expires.getTime()) {
+ // delete the long-term verification token after verification
+ await prisma.verificationToken.delete({
+ where: {
+ token: token,
+ },
+ });
+ return NextResponse.json(
+ {
+ message: "Access expired. Request new access.",
+ resetVerification: true,
+ },
+ { status: 401 },
+ );
+ }
+
+ isEmailVerified = true;
+ }
}
// Check if there's a valid preview session
let previewSession: PreviewSession | null = null;
- let isPreview: boolean = false;
- if (previewToken) {
+ if (!isPreview && previewToken) {
const session = await getServerSession(authOptions);
if (!session) {
return NextResponse.json(
@@ -623,6 +651,7 @@ export async function POST(request: NextRequest) {
: LOCALHOST_IP
: undefined,
verificationToken: hashedVerificationToken ?? undefined,
+ isTeamMember: isTeamMember ? true : undefined,
};
return NextResponse.json(returnObject);
diff --git a/components/links/links-table.tsx b/components/links/links-table.tsx
index 92bee916..9fd5c4b6 100644
--- a/components/links/links-table.tsx
+++ b/components/links/links-table.tsx
@@ -1,8 +1,6 @@
import { useSearchParams } from "next/navigation";
import { useRouter } from "next/router";
-
-
import { useMemo, useState } from "react";
import { useTeam } from "@/context/team-context";
@@ -556,6 +554,12 @@ export default function LinksTable({
<Settings2Icon className="mr-2 h-4 w-4" />
Edit Link
</DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => handlePreviewLink(link)}
+ >
+ <EyeIcon className="mr-2 h-4 w-4" />
+ Preview Link
+ </DropdownMenuItem>
<DropdownMenuItem
disabled={!canAddLinks}
onClick={() => handleDuplicateLink(link)}
@@ -793,4 +797,4 @@ export default function LinksTable({
</div>
</>
);
-}
\ No newline at end of file
+}
diff --git a/components/view/dataroom/dataroom-document-view.tsx b/components/view/dataroom/dataroom-document-view.tsx
index b8447149..c7974e3d 100644
--- a/components/view/dataroom/dataroom-document-view.tsx
+++ b/components/view/dataroom/dataroom-document-view.tsx
@@ -57,6 +57,7 @@ export type DEFAULT_DATAROOM_DOCUMENT_VIEW_TYPE = {
viewerEmail?: string;
viewerId?: string;
conversationsEnabled?: boolean;
+ isTeamMember?: boolean;
};
export default function DataroomDocumentView({
@@ -174,6 +175,7 @@ export default function DataroomDocumentView({
viewerEmail,
viewerId,
conversationsEnabled,
+ isTeamMember,
} = fetchData as DEFAULT_DATAROOM_DOCUMENT_VIEW_TYPE;
analytics.identify(
userEmail ?? viewerEmail ?? verifiedEmail ?? data.email ?? undefined,
@@ -186,6 +188,7 @@ export default function DataroomDocumentView({
viewerId: viewerId,
viewerEmail: viewerEmail ?? data.email ?? verifiedEmail ?? userEmail,
isEmbedded,
+ isTeamMember,
});
// set the verification token to the cookie
@@ -215,6 +218,7 @@ export default function DataroomDocumentView({
viewerEmail,
viewerId,
conversationsEnabled,
+ isTeamMember,
}));
setSubmitted(true);
setVerificationRequested(false);
@@ -252,13 +256,21 @@ export default function DataroomDocumentView({
(!submitted && !isProtected) ||
token ||
preview ||
- viewData.dataroomViewId
+ viewData.dataroomViewId ||
+ previewToken
) {
handleSubmission();
didMount.current = true;
}
}
- }, [submitted, isProtected, token, preview, viewData.dataroomViewId]);
+ }, [
+ submitted,
+ isProtected,
+ token,
+ preview,
+ viewData.dataroomViewId,
+ previewToken,
+ ]);
// Components to render when email is submitted but verification is pending
if (verificationRequested) {
diff --git a/components/view/dataroom/dataroom-view.tsx b/components/view/dataroom/dataroom-view.tsx
index 690dc4dc..68ce0975 100644
--- a/components/view/dataroom/dataroom-view.tsx
+++ b/components/view/dataroom/dataroom-view.tsx
@@ -41,6 +41,7 @@ export type DEFAULT_DATAROOM_VIEW_TYPE = {
viewerId?: string;
conversationsEnabled?: boolean;
enableVisitorUpload?: boolean;
+ isTeamMember?: boolean;
};
export default function DataroomView({
@@ -138,6 +139,7 @@ export default function DataroomView({
viewerId,
conversationsEnabled,
enableVisitorUpload,
+ isTeamMember,
} = fetchData as DEFAULT_DATAROOM_VIEW_TYPE;
analytics.identify(
@@ -150,6 +152,7 @@ export default function DataroomView({
viewerId: viewerId,
viewerEmail: viewerEmail ?? data.email ?? verifiedEmail ?? userEmail,
isEmbedded,
+ isTeamMember,
});
// set the verification token to the cookie
@@ -170,6 +173,7 @@ export default function DataroomView({
viewerId,
conversationsEnabled,
enableVisitorUpload,
+ isTeamMember,
});
setSubmitted(true);
setVerificationRequested(false);
@@ -202,12 +206,12 @@ export default function DataroomView({
// If link is not submitted and does not have email / password protection, show the access form
useEffect(() => {
if (!didMount.current) {
- if ((!submitted && !isProtected) || token || preview) {
+ if ((!submitted && !isProtected) || token || preview || previewToken) {
handleSubmission();
didMount.current = true;
}
}
- }, [submitted, isProtected, token, preview]);
+ }, [submitted, isProtected, token, preview, previewToken]);
// Components to render when email is submitted but verification is pending
if (verificationRequested) {
diff --git a/components/view/dataroom/nav-dataroom.tsx b/components/view/dataroom/nav-dataroom.tsx
index 46c101db..3ff4917e 100644
--- a/components/view/dataroom/nav-dataroom.tsx
+++ b/components/view/dataroom/nav-dataroom.tsx
@@ -3,7 +3,7 @@ import Link from "next/link";
import React, { useEffect, useState } from "react";
import { DataroomBrand } from "@prisma/client";
-import { Download, MessagesSquareIcon } from "lucide-react";
+import { BadgeInfoIcon, Download, MessagesSquareIcon } from "lucide-react";
import { toast } from "sonner";
import { formatDate } from "@/lib/utils";
@@ -28,6 +28,7 @@ export default function DataroomNav({
dataroomId,
viewerId,
conversationsEnabled,
+ isTeamMember,
}: {
allowDownload?: boolean;
brand?: Partial<DataroomBrand>;
@@ -38,6 +39,7 @@ export default function DataroomNav({
dataroomId?: string;
viewerId?: string;
conversationsEnabled?: boolean;
+ isTeamMember?: boolean;
}) {
const [loading, setLoading] = useState<boolean>(false);
const [showConversations, setShowConversations] = useState<boolean>(false);
@@ -147,8 +149,28 @@ export default function DataroomNav({
</div>
</div>
<div className="absolute inset-y-0 right-0 flex items-center space-x-4 pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0">
+ {isTeamMember ? (
+ <TooltipProvider delayDuration={100}>
+ <Tooltip defaultOpen>
+ <TooltipTrigger asChild>
+ <Button
+ className="size-8 bg-gray-900 text-white hover:bg-gray-900/80 sm:size-10"
+ size="icon"
+ >
+ <BadgeInfoIcon className="h-5 w-5" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p className="max-w-xs text-wrap text-center">
+ Skipped verification because you are a team member; no
+ analytics will be collected
+ </p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ ) : null}
{conversationsEnabled && (
- <TooltipProvider>
+ <TooltipProvider delayDuration={100}>
<Tooltip>
<TooltipTrigger asChild>
<Button
diff --git a/components/view/document-view.tsx b/components/view/document-view.tsx
index 685f689c..fba67beb 100644
--- a/components/view/document-view.tsx
+++ b/components/view/document-view.tsx
@@ -44,6 +44,7 @@ export type DEFAULT_DOCUMENT_VIEW_TYPE = {
isPreview?: boolean;
ipAddress?: string;
verificationToken?: string;
+ isTeamMember?: boolean;
};
export default function DocumentView({
@@ -152,6 +153,7 @@ export default function DocumentView({
isPreview,
ipAddress,
verificationToken,
+ isTeamMember,
} = fetchData as DEFAULT_DOCUMENT_VIEW_TYPE;
plausible("documentViewed"); // track the event
analytics.identify(
@@ -164,6 +166,7 @@ export default function DocumentView({
viewerId: viewId,
viewerEmail: data.email ?? verifiedEmail ?? userEmail,
isEmbedded,
+ isTeamMember,
});
// set the verification token to the cookie
@@ -185,6 +188,7 @@ export default function DocumentView({
fileType,
isPreview,
ipAddress,
+ isTeamMember,
});
setSubmitted(true);
setVerificationRequested(false);
@@ -217,12 +221,12 @@ export default function DocumentView({
// If link is not submitted and does not have email / password protection, show the access form
useEffect(() => {
if (!didMount.current) {
- if ((!submitted && !isProtected) || token) {
+ if ((!submitted && !isProtected) || token || previewToken) {
handleSubmission();
}
didMount.current = true;
}
- }, [submitted, isProtected, token]);
+ }, [submitted, isProtected, token, previewToken]);
// Components to render when email is submitted but verification is pending
if (verificationRequested) {
diff --git a/components/view/nav.tsx b/components/view/nav.tsx
index 473aa256..cc075fc8 100644
--- a/components/view/nav.tsx
+++ b/components/view/nav.tsx
@@ -6,6 +6,7 @@ import React, { useEffect, useState } from "react";
import { Brand, DataroomBrand } from "@prisma/client";
import {
ArrowUpRight,
+ BadgeInfoIcon,
Download,
MessageCircle,
Slash,
@@ -55,10 +56,10 @@ export type TNavData = {
viewerId?: string;
isMobile?: boolean;
isPreview?: boolean;
-
dataroomId?: string;
conversationsEnabled?: boolean;
assistantEnabled?: boolean;
+ isTeamMember?: boolean;
};
export default function Nav({
@@ -97,6 +98,7 @@ export default function Nav({
dataroomId,
conversationsEnabled,
assistantEnabled,
+ isTeamMember,
} = navData;
const [showConversations, setShowConversations] = useState(false);
@@ -248,9 +250,29 @@ export default function Nav({
) : null}
</div>
<div className="absolute inset-y-0 right-0 flex items-center space-x-2 pr-2 sm:static sm:inset-auto sm:ml-6 sm:space-x-4 sm:pr-0">
+ {isTeamMember && (
+ <TooltipProvider delayDuration={100}>
+ <Tooltip defaultOpen>
+ <TooltipTrigger asChild>
+ <Button
+ className="size-8 bg-gray-900 text-white hover:bg-gray-900/80 sm:size-10"
+ size="icon"
+ >
+ <BadgeInfoIcon className="h-5 w-5" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p className="max-w-xs text-wrap text-center">
+ Skipped verification because you are a team member; no
+ analytics will be collected
+ </p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ )}
{/* Conversation toggle button for dataroom documents */}
{isDataroom && conversationsEnabled && (
- <TooltipProvider>
+ <TooltipProvider delayDuration={100}>
<Tooltip>
<TooltipTrigger asChild>
<Button
diff --git a/components/view/view-data.tsx b/components/view/view-data.tsx
index d171d6e6..41ed08bc 100644
--- a/components/view/view-data.tsx
+++ b/components/view/view-data.tsx
@@ -94,6 +94,7 @@ export default function ViewData({
: false),
assistantEnabled: document.assistantEnabled,
allowDownload: isDownloadAllowed(canDownload, link.allowDownload ?? false),
+ isTeamMember: viewData.isTeamMember,
};
// Calculate allowDownload once for all components
diff --git a/components/view/viewer/dataroom-viewer.tsx b/components/view/viewer/dataroom-viewer.tsx
index a9eadc8b..26bb53a6 100644
--- a/components/view/viewer/dataroom-viewer.tsx
+++ b/components/view/viewer/dataroom-viewer.tsx
@@ -215,6 +215,7 @@ export default function DataroomViewer({
dataroomId={dataroom?.id}
viewerId={viewerId}
conversationsEnabled={viewData.conversationsEnabled}
+ isTeamMember={viewData.isTeamMember}
/>
<div
style={{ height: "calc(100vh - 64px)" }}