fix: locked users admin list and bypass query (#17902)
This commit is contained in:
1 parent
f2efd6dc28
commit
249bcaca68
2 files changed
+18
-6
No files matched your search
@@ -25,6 +25,14 @@ export function excludeLockedUsersExtension() {
|
||||
});
|
||||
}
|
||||
|
||||
function safeJSONStringify(x: any) {
|
||||
try {
|
||||
return JSON.stringify(x);
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
async function excludeLockedUsers(
|
||||
args:
|
||||
| Prisma.UserFindUniqueArgs<InternalArgs & DefaultArgs>
|
||||
@@ -35,8 +43,10 @@ async function excludeLockedUsers(
|
||||
query: <T>(args: T) => Promise<unknown>
|
||||
) {
|
||||
args.where = args.where || {};
|
||||
const whereString = safeJSONStringify(args.where);
|
||||
const shouldIncludeLocked = whereString.includes('"locked":');
|
||||
// Unless explicitly specified, we exclude locked users
|
||||
if (args.where.locked === undefined) {
|
||||
if (!shouldIncludeLocked) {
|
||||
args.where.locked = false;
|
||||
}
|
||||
return query(args);
|
||||
|
||||
Reference in new issue
Block a user