fix: locked users admin list and bypass query (#17902)

This commit is contained in:
Omar López authored and GitHub committed 2024-11-28 21:45:40 +00:00
1 parent f2efd6dc28
commit 249bcaca68
2 files changed
+18 -6

No files matched your search

@@ -17,9 +17,12 @@ const listPaginatedHandler = async ({ input }: GetOptions) => {
const getTotalUsers = await prisma.user.count();
let searchFilters: Prisma.UserWhereInput = {};
const bothLockedAndUnlockedWhere = { OR: [{ locked: false }, { locked: true }] };
if (searchTerm) {
searchFilters = {
// To bypass the excludeLockedUsersExtension
AND: bothLockedAndUnlockedWhere,
OR: [
{
email: {
@@ -33,16 +36,15 @@ const listPaginatedHandler = async ({ input }: GetOptions) => {
},
],
};
} else {
// To bypass the excludeLockedUsersExtension
searchFilters = bothLockedAndUnlockedWhere;
}
const users = await prisma.user.findMany({
cursor: cursor ? { id: cursor } : undefined,
take: limit + 1, // We take +1 as itll be used for the next cursor
where: {
...searchFilters,
// To bypass the excludeLockedUsersExtension
OR: [{ locked: false }, { locked: true }],
},
where: searchFilters,
orderBy: {
id: "asc",
},