feat(auth): add /login page, session middleware, role-based navigation and logout
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user