Skip to content

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

feat(verify): remove url params if reshared

Marc Seitz56edfd81ed48
diff --git a/components/view/dataroom/dataroom-view.tsx b/components/view/dataroom/dataroom-view.tsx
index 9bcdb620..35c74723 100644
--- a/components/view/dataroom/dataroom-view.tsx
+++ b/components/view/dataroom/dataroom-view.tsx
@@ -141,8 +141,23 @@ export default function DataroomView({
setIsLoading(false);
}
} else {
- const { message } = await response.json();
- toast.error(message);
+ const data = await response.json();
+ toast.error(data.message);
+
+ if (data.resetVerification) {
+ const currentQuery = { ...router.query };
+ delete currentQuery.token;
+ delete currentQuery.email;
+
+ router.replace(
+ {
+ pathname: router.pathname,
+ query: currentQuery,
+ },
+ undefined,
+ { shallow: true },
+ );
+ }
setIsLoading(false);
}
};
@@ -265,6 +280,7 @@ export default function DataroomView({
dataroom={dataroom}
setDocumentData={setDocumentData}
setViewType={setViewType}
+ setDataroomVerified={setDataroomVerified}
/>
</div>
);
diff --git a/components/view/document-view.tsx b/components/view/document-view.tsx
index 04f987de..c194c88a 100644
--- a/components/view/document-view.tsx
+++ b/components/view/document-view.tsx
@@ -115,8 +115,23 @@ export default function DocumentView({
setIsLoading(false);
}
} else {
- const { message } = await response.json();
- toast.error(message);
+ const data = await response.json();
+ toast.error(data.message);
+
+ if (data.resetVerification) {
+ const currentQuery = { ...router.query };
+ delete currentQuery.token;
+ delete currentQuery.email;
+
+ router.replace(
+ {
+ pathname: router.pathname,
+ query: currentQuery,
+ },
+ undefined,
+ { shallow: true },
+ );
+ }
setIsLoading(false);
}
};
diff --git a/pages/api/views-dataroom.ts b/pages/api/views-dataroom.ts
index d4d5bdcd..e0f183d2 100644
--- a/pages/api/views-dataroom.ts
+++ b/pages/api/views-dataroom.ts
@@ -193,7 +193,10 @@ export default async function handle(
});
if (!verification) {
- res.status(401).json({ message: "Unauthorized access" });
+ res.status(401).json({
+ message: "Unauthorized access. Request new access.",
+ resetVerification: true,
+ });
return;
}
diff --git a/pages/api/views.ts b/pages/api/views.ts
index e9c55a17..fa9fb061 100644
--- a/pages/api/views.ts
+++ b/pages/api/views.ts
@@ -179,7 +179,10 @@ export default async function handle(
});
if (!verification) {
- res.status(401).json({ message: "Unauthorized access" });
+ res.status(401).json({
+ message: "Unauthorized access. Request new access.",
+ resetVerification: true,
+ });
return;
}