added the ability for the users to hide there profile
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ export default async function (user: AccountSettings, userId: number) {
|
||||
data: {
|
||||
name: user.name,
|
||||
email: user.email,
|
||||
collectionProtection: user.collectionProtection,
|
||||
isPrivate: user.isPrivate,
|
||||
whitelistedUsers: user.whitelistedUsers,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user