feat(auth): add /login page, session middleware, role-based navigation and logout

This commit is contained in:
Marcos Fargas
2026-09-21 02:20:09 +02:00
parent f728c33533
commit 3bcdb6379f
5 changed files with 323 additions and 42 deletions

View File

@@ -1,5 +1,13 @@
import { redirect } from 'next/navigation';
import { createClient } from '@/lib/supabase/server';
export default function Home() {
redirect('/dashboard/kpis');
export default async function Home() {
const supabase = await createClient();
const { data: { user } } = await supabase.auth.getUser();
if (user) {
redirect('/dashboard/kpis');
} else {
redirect('/login');
}
}