hermes-web/lib/current-user.ts

18 lines
378 B
TypeScript
Raw Normal View History

2023-12-30 05:56:40 -05:00
import { db } from "@/lib/db"
import { useSession } from "next-auth/react"
export const currentUser = async() => {
const { data: session, status } = useSession()
if (status !== "authenticated") {
return null;
}
const user = await db.user.findUnique({
where: {
id: session?.user?.name as string
}
});
return user;
}