Skip to content

Commit

Permalink
fix: personal site not openning
Browse files Browse the repository at this point in the history
  • Loading branch information
Bekacru committed Jan 29, 2024
1 parent 3f7d3bc commit 9d3e9e9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions apps/www/src/app/(app)/s/[website]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getWebsite } from "@/server/query/website";
import { schema } from "@loglib/db";
import { PLAN } from "@loglib/types/models";
import { eq } from "drizzle-orm";
import { redirect } from "next/navigation";
import { notFound, redirect } from "next/navigation";

export default async function Page({
params,
Expand All @@ -19,7 +19,7 @@ export default async function Page({
id: user?.id ?? "public",
website: params.website as string,
});
const { userWebsites, teamWebsites } = await getWebsite();
const { teamWebsites } = await getWebsite();
const website = await db.query.website.findFirst({
with: {
user: {
Expand All @@ -35,11 +35,13 @@ export default async function Page({
}
});
if (!website) {
return redirect("/");
return notFound()
}
const isAuthed = website.userId === user?.id || !!teamWebsites.find(w => w.id === params.website);

if (!isAuthed || !website.public) {
const isTeamMember = !!teamWebsites.find(w => w.id === params.website);
const isAuthed = website.userId === user?.id || isTeamMember

if (!isAuthed && !website.public) {
return redirect("/");
}

Expand Down

0 comments on commit 9d3e9e9

Please sign in to comment.