hermes-web/lib/current-user.ts
2023-12-30 10:56:40 +00:00

18 lines
378 B
TypeScript

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;
}