Redirect to role-based dashboard after login

This commit is contained in:
2026-04-07 11:13:24 +05:00
parent 4e6ab6fd2b
commit b480b56caf
+11 -2
View File
@@ -3,7 +3,7 @@
import { useState } from "react";
import { useRouter } from "next/navigation";
import Link from "next/link";
import { signIn } from "@/lib/auth-client";
import { signIn, authClient } from "@/lib/auth-client";
export function LoginForm() {
const router = useRouter();
@@ -25,7 +25,16 @@ export function LoginForm() {
return;
}
router.push("/dashboard");
const session = await authClient.getSession();
const role = session.data?.user?.role;
if (role === "admin") {
router.push("/admin/dashboard");
} else if (role === "curator") {
router.push("/curator/dashboard");
} else {
router.push("/dashboard");
}
router.refresh();
}