Redirect to role-based dashboard after login
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user