client: don't re-direct the owner of a file if it's expired
This commit is contained in:
parent
9fe9b818c4
commit
d1415d1ee2
1 changed files with 2 additions and 2 deletions
|
@ -29,10 +29,10 @@ const PostPage = ({ post }: Props) => {
|
||||||
const [isExpired, setIsExpired] = useState(post.expiresAt ? new Date(post.expiresAt) < new Date() : null)
|
const [isExpired, setIsExpired] = useState(post.expiresAt ? new Date(post.expiresAt) < new Date() : null)
|
||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isExpired) {
|
const isOwner = post.users ? post.users[0].id === Cookies.get("drift-userid") : false
|
||||||
|
if (!isOwner && isExpired) {
|
||||||
router.push("/expired")
|
router.push("/expired")
|
||||||
}
|
}
|
||||||
const isOwner = post.users ? post.users[0].id === Cookies.get("drift-userid") : false
|
|
||||||
|
|
||||||
const expirationDate = new Date(post.expiresAt ? post.expiresAt : "")
|
const expirationDate = new Date(post.expiresAt ? post.expiresAt : "")
|
||||||
if (!isOwner && expirationDate < new Date()) {
|
if (!isOwner && expirationDate < new Date()) {
|
||||||
|
|
Loading…
Reference in a new issue