mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
🐛
This commit is contained in:
@ -114,21 +114,23 @@ export async function getServerSideProps(context: any) {
|
||||
|
||||
const { id: documentId } = context.query;
|
||||
|
||||
const document: PrismaDocument = await getDocument(
|
||||
+documentId,
|
||||
context.req,
|
||||
context.res
|
||||
);
|
||||
try {
|
||||
const document: PrismaDocument = await getDocument(
|
||||
+documentId,
|
||||
context.req,
|
||||
context.res
|
||||
);
|
||||
} catch (error) {
|
||||
if (!document) {
|
||||
return {
|
||||
notFound: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// todo optimize querys
|
||||
// todo no intersection groups
|
||||
|
||||
if (!document) {
|
||||
return {
|
||||
notFound: true,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
document: document,
|
||||
|
||||
@ -12,7 +12,7 @@ export const getDocument = async (
|
||||
if (!documentId) Promise.reject("No documentId");
|
||||
if (!req || !res) Promise.reject("No res or req");
|
||||
|
||||
const document: PrismaDocument = await prisma.document.findFirst({
|
||||
const document: PrismaDocument = await prisma.document.findFirstOrThrow({
|
||||
where: {
|
||||
id: documentId,
|
||||
userId: user.id,
|
||||
|
||||
Reference in New Issue
Block a user