From 2cf416da60a129f9ff62c143fcb1a3466d08907a Mon Sep 17 00:00:00 2001 From: Esdras Renan Date: Tue, 14 Oct 2025 10:23:58 -0300 Subject: [PATCH] =?UTF-8?q?home:=20redirecionar=20por=20sess=C3=A3o=20no?= =?UTF-8?q?=20servidor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Em /, decidir destino via getServerSession(): - Sem sessão: /login - Staff: /dashboard - Colaborador: /portal - Evita depender do redirect client-side e garante comportamento correto em aba anônima. --- src/app/page.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 8878c5f..442982d 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,5 +1,14 @@ -import { redirect } from "next/navigation" - -export default function Home() { - redirect("/dashboard") -} +import { redirect } from "next/navigation" +import { getServerSession } from "@/lib/auth-server" +import { isStaff } from "@/lib/authz" + +export default async function Home() { + const session = await getServerSession() + if (!session?.user) { + redirect("/login") + } + if (isStaff(session.user.role)) { + redirect("/dashboard") + } + redirect("/portal") +}