Update-remaining-files

This commit is contained in:
SpecialX
2026-02-24 16:07:15 +08:00
parent a2e89ce795
commit ac859ee560
4 changed files with 17 additions and 3 deletions

View File

@@ -3,11 +3,17 @@ import { auth } from "@/auth"
export const dynamic = "force-dynamic"
const normalizeRole = (value: unknown) => {
const role = String(value ?? "").trim().toLowerCase()
if (role === "admin" || role === "student" || role === "teacher" || role === "parent") return role
return "student"
}
export default async function DashboardPage() {
const session = await auth()
if (!session?.user) redirect("/login")
const role = String(session.user.role ?? "teacher")
const role = normalizeRole(session.user.role)
if (role === "admin") redirect("/admin/dashboard")
if (role === "student") redirect("/student/dashboard")