From aa5b12536723c1697a0e876f1f4f901cb4d4b33e Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Fri, 14 Oct 2022 12:21:26 +0200 Subject: [PATCH] fix: share not found if unauthenticated --- backend/src/share/share.service.ts | 11 +++++++++-- frontend/src/pages/_app.tsx | 4 ---- frontend/src/pages/share/[shareId].tsx | 12 ++++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/backend/src/share/share.service.ts b/backend/src/share/share.service.ts index e417fd9..602e82e 100644 --- a/backend/src/share/share.service.ts +++ b/backend/src/share/share.service.ts @@ -99,12 +99,19 @@ export class ShareService { async getSharesByUser(userId: string) { return await this.prisma.share.findMany({ - where: { creator: { id: userId }, expiration: { gt: new Date() } }, + where: { + creator: { id: userId }, + expiration: { gt: new Date() }, + uploadLocked: true, + }, + orderBy: { + expiration: "desc", + }, }); } async get(id: string) { - const share : any = await this.prisma.share.findUnique({ + const share: any = await this.prisma.share.findUnique({ where: { id }, include: { files: true, diff --git a/frontend/src/pages/_app.tsx b/frontend/src/pages/_app.tsx index 266fcbc..78bd0e8 100644 --- a/frontend/src/pages/_app.tsx +++ b/frontend/src/pages/_app.tsx @@ -8,7 +8,6 @@ import { import { useColorScheme } from "@mantine/hooks"; import { ModalsProvider } from "@mantine/modals"; import { NotificationsProvider } from "@mantine/notifications"; -import { setCookies } from "cookies-next"; import type { AppProps } from "next/app"; import { useEffect, useState } from "react"; import Footer from "../components/Footer"; @@ -41,9 +40,6 @@ function App({ Component, pageProps }: AppProps) { }, []); useEffect(() => { - setCookies("color-schema", systemTheme, { - maxAge: 60 * 60 * 24 * 30, - }); setColorScheme(systemTheme); }, [systemTheme]); diff --git a/frontend/src/pages/share/[shareId].tsx b/frontend/src/pages/share/[shareId].tsx index 21b23fd..2555f79 100644 --- a/frontend/src/pages/share/[shareId].tsx +++ b/frontend/src/pages/share/[shareId].tsx @@ -1,6 +1,6 @@ import { Group } from "@mantine/core"; import { useModals } from "@mantine/modals"; -import { useRouter } from "next/router"; +import { GetServerSidePropsContext } from "next"; import { useEffect, useState } from "react"; import Meta from "../../components/Meta"; import DownloadAllButton from "../../components/share/DownloadAllButton"; @@ -9,10 +9,14 @@ import showEnterPasswordModal from "../../components/share/showEnterPasswordModa import showErrorModal from "../../components/share/showErrorModal"; import shareService from "../../services/share.service"; -const Share = () => { - const router = useRouter(); +export function getServerSideProps(context: GetServerSidePropsContext) { + return { + props: { shareId: context.params!.shareId }, + }; +} + +const Share = ({ shareId }: { shareId: string }) => { const modals = useModals(); - const shareId = router.query.shareId as string; const [fileList, setFileList] = useState([]); const getShareToken = async (password?: string) => {