24 lines
576 B
TypeScript
24 lines
576 B
TypeScript
import { getServerSession } from "next-auth/next";
|
|
import { authOptions } from "../../api/auth/[...nextauth]/route";
|
|
import prisma from "@/lib/prisma";
|
|
|
|
export const getAnotherUserData = async () => {
|
|
try {
|
|
const session = await getServerSession(authOptions);
|
|
|
|
if (!session?.user?.email) return null;
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: { email: session.user.email },
|
|
select: {
|
|
gender: true,
|
|
},
|
|
});
|
|
|
|
return user;
|
|
} catch (error) {
|
|
console.error("Error fetching user data:", error);
|
|
return null;
|
|
}
|
|
};
|