mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-18 21:44:06 +01:00
feat: can only access own's project edit page
This commit is contained in:
parent
8a826e0b90
commit
578cff2507
@ -4,11 +4,26 @@ import { Separator } from "@/components/ui/separator";
|
||||
import { getProjectDataQuery } from "@/lib/data/projectQuery";
|
||||
import { createSupabaseClient } from "@/lib/supabase/serverComponentClient";
|
||||
import { ProjectEditSchema } from "@/types/schemas/project.schema";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function EditProjectPage({ params }: { params: { projectId: string } }) {
|
||||
const client = createSupabaseClient();
|
||||
const projectId = Number(params.projectId);
|
||||
|
||||
// Check permission
|
||||
const { data: user, error: userError } = await client.auth.getUser();
|
||||
const uuid = user.user?.id;
|
||||
const { data, error } = await client.from("project").select("...business(user_id)").eq("id", projectId).single();
|
||||
console.log(uuid);
|
||||
console.log(data);
|
||||
if (userError || error) {
|
||||
redirect("/");
|
||||
}
|
||||
|
||||
if (data.user_id != uuid || data == null) {
|
||||
redirect("/");
|
||||
}
|
||||
|
||||
const { data: projectData, error: projectDataError } = await getProjectDataQuery(client, projectId);
|
||||
|
||||
if (projectDataError) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user