From d1415d1ee2fba8b04f87ffc44f64b8fd3e3759b9 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Fri, 8 Apr 2022 23:30:07 -0700 Subject: [PATCH] client: don't re-direct the owner of a file if it's expired --- client/components/post-page/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/components/post-page/index.tsx b/client/components/post-page/index.tsx index 692fb779..403048aa 100644 --- a/client/components/post-page/index.tsx +++ b/client/components/post-page/index.tsx @@ -29,10 +29,10 @@ const PostPage = ({ post }: Props) => { const [isExpired, setIsExpired] = useState(post.expiresAt ? new Date(post.expiresAt) < new Date() : null) const [isLoading, setIsLoading] = useState(true) useEffect(() => { - if (isExpired) { + const isOwner = post.users ? post.users[0].id === Cookies.get("drift-userid") : false + if (!isOwner && isExpired) { router.push("/expired") } - const isOwner = post.users ? post.users[0].id === Cookies.get("drift-userid") : false const expirationDate = new Date(post.expiresAt ? post.expiresAt : "") if (!isOwner && expirationDate < new Date()) {