home: redirecionar por sessão no servidor
- 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.
This commit is contained in:
parent
c88622d762
commit
2cf416da60
1 changed files with 14 additions and 5 deletions
|
|
@ -1,5 +1,14 @@
|
|||
import { redirect } from "next/navigation"
|
||||
import { getServerSession } from "@/lib/auth-server"
|
||||
import { isStaff } from "@/lib/authz"
|
||||
|
||||
export default function Home() {
|
||||
redirect("/dashboard")
|
||||
export default async function Home() {
|
||||
const session = await getServerSession()
|
||||
if (!session?.user) {
|
||||
redirect("/login")
|
||||
}
|
||||
if (isStaff(session.user.role)) {
|
||||
redirect("/dashboard")
|
||||
}
|
||||
redirect("/portal")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue