minor fix
This commit is contained in:
parent
a56b8e24da
commit
02b7a90160
|
@ -50,9 +50,11 @@ export default async function updateUser(
|
|||
email: user.email?.toLowerCase(),
|
||||
},
|
||||
]
|
||||
: {
|
||||
: [
|
||||
{
|
||||
username: user.username.toLowerCase(),
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -112,18 +114,19 @@ export default async function updateUser(
|
|||
: undefined,
|
||||
},
|
||||
include: {
|
||||
whitelistedUsers: true
|
||||
}
|
||||
whitelistedUsers: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const { whitelistedUsers, password, ...userInfo } = updatedUser;
|
||||
|
||||
// If user.whitelistedUsers is not provided, we will assume the whitelistedUsers should be removed
|
||||
const newWhitelistedUsernames: string[] = user.whitelistedUsers || [];
|
||||
|
||||
// Get the current whitelisted usernames
|
||||
const currentWhitelistedUsernames: string[] = whitelistedUsers.map((user) => user.username);
|
||||
const currentWhitelistedUsernames: string[] = whitelistedUsers.map(
|
||||
(user) => user.username
|
||||
);
|
||||
|
||||
// Find the usernames to be deleted (present in current but not in new)
|
||||
const usernamesToDelete: string[] = currentWhitelistedUsernames.filter(
|
||||
|
@ -132,7 +135,8 @@ export default async function updateUser(
|
|||
|
||||
// Find the usernames to be created (present in new but not in current)
|
||||
const usernamesToCreate: string[] = newWhitelistedUsernames.filter(
|
||||
(username) => !currentWhitelistedUsernames.includes(username) && username.trim() !== ''
|
||||
(username) =>
|
||||
!currentWhitelistedUsernames.includes(username) && username.trim() !== ""
|
||||
);
|
||||
|
||||
// Delete whitelistedUsers that are not present in the new list
|
||||
|
@ -155,7 +159,6 @@ export default async function updateUser(
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
const STRIPE_SECRET_KEY = process.env.STRIPE_SECRET_KEY;
|
||||
const PRICE_ID = process.env.PRICE_ID;
|
||||
|
||||
|
|
|
@ -10,9 +10,10 @@ export const prisma =
|
|||
|
||||
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
|
||||
|
||||
if (process.env.NODE_ENV !== "production")
|
||||
prisma.$on("query" as any, (e: any) => {
|
||||
console.log("Query: " + e.query);
|
||||
console.log("Params: " + e.params);
|
||||
console.log("\x1b[31m", `Duration: ${e.duration}ms`, "\x1b[0m"); // For benchmarking
|
||||
});
|
||||
// For benchmarking | uncomment when needed
|
||||
// if (process.env.NODE_ENV !== "production")
|
||||
// prisma.$on("query" as any, (e: any) => {
|
||||
// console.log("Query: " + e.query);
|
||||
// console.log("Params: " + e.params);
|
||||
// console.log("\x1b[31m", `Duration: ${e.duration}ms`, "\x1b[0m");
|
||||
// });
|
||||
|
|
Ŝarĝante…
Reference in New Issue