diff --git a/apps/web/app/app/(dashboard)/layout.tsx b/apps/web/app/app/(dashboard)/layout.tsx
index 3ec6474..4a9ed2f 100644
--- a/apps/web/app/app/(dashboard)/layout.tsx
+++ b/apps/web/app/app/(dashboard)/layout.tsx
@@ -1,5 +1,4 @@
import React, { ReactNode, Suspense } from 'react';
-import { headers } from 'next/headers';
import Link from 'next/link';
import { redirect } from 'next/navigation';
@@ -19,7 +18,10 @@ export default async function DashboardLayout({ children }: { children: ReactNod
const supabase = createAdminClient();
- const { data: workspaces } = await supabase.from('workspaces').select('*');
+ const { data: workspaces } = await supabase
+ .from('workspaces')
+ .select('*, workspace_users(*)')
+ .eq('workspace_users.user_id', user.id);
return (
diff --git a/apps/web/app/app/(dashboard)/page.tsx b/apps/web/app/app/(dashboard)/page.tsx
index 89929f7..93c1574 100644
--- a/apps/web/app/app/(dashboard)/page.tsx
+++ b/apps/web/app/app/(dashboard)/page.tsx
@@ -1,19 +1,27 @@
import React from 'react';
import Link from 'next/link';
+import { redirect } from 'next/navigation';
import { ArrowUpRightIcon } from 'lucide-react';
import { CreateWorkspaceSheet } from '@saasfy/components';
-import { createAdminClient } from '@saasfy/supabase/server';
+import { createAdminClient, getUser } from '@saasfy/supabase/server';
import { Badge } from '@saasfy/ui/badge';
import { Button } from '@saasfy/ui/button';
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@saasfy/ui/table';
export default async function Component() {
+ const user = await getUser();
+
+ if (!user) {
+ return redirect('/login');
+ }
+
const supabase = createAdminClient();
const { data: workspaces } = await supabase
.from('workspaces')
.select('*, projects(id), domains(id), workspace_users(id), plans(name)')
+ .eq('user_id', user.id)
.limit(8);
return (
diff --git a/apps/web/app/app/(user)/settings/page.tsx b/apps/web/app/app/(user)/settings/page.tsx
index c2895df..81c0a7f 100644
--- a/apps/web/app/app/(user)/settings/page.tsx
+++ b/apps/web/app/app/(user)/settings/page.tsx
@@ -53,7 +53,7 @@ export default async function Settings() {
diff --git a/supabase/migrations/20240506132736_invite_email_unique.sql b/supabase/migrations/20240506132736_invite_email_unique.sql
deleted file mode 100644
index 496311b..0000000
--- a/supabase/migrations/20240506132736_invite_email_unique.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE workspace_invites ADD CONSTRAINT unique_email_per_workspace UNIQUE (email, workspace_id);