added the ability for the users to hide there profile

This commit is contained in:
Daniel
2023-05-23 07:38:16 +03:30
parent e774f41d37
commit 240d92aeae
10 changed files with 94 additions and 34 deletions
+14 -2
View File
@@ -5,14 +5,26 @@
import { prisma } from "@/lib/api/db";
export default async function (lookupEmail: string, isSelf: boolean) {
export default async function (
lookupEmail: string,
isSelf: boolean,
userEmail: string
) {
const user = await prisma.user.findUnique({
where: {
email: lookupEmail,
},
});
if (!user) return { response: "User not found." || null, status: 404 };
if (!user) return { response: "User not found.", status: 404 };
if (
!isSelf &&
user?.isPrivate &&
!user.whitelistedUsers.includes(userEmail)
) {
return { response: "This profile is private.", status: 401 };
}
const { password, ...unsensitiveInfo } = user;