add server side filter for server admin

This commit is contained in:
miloschwartz
2026-09-11 11:28:07 -04:00
committed by Owen
parent 07bea71cb9
commit dfe7f60244
4 changed files with 95 additions and 38 deletions
+15 -1
View File
@@ -88,6 +88,15 @@ const listUsersSchema = z.strictObject({
type: "boolean",
description:
"Filter by 2FA state matching: enabled if twoFactorEnabled or twoFactorSetupRequested"
}),
server_admin: z
.enum(["true", "false"])
.transform((v) => v === "true")
.optional()
.catch(undefined)
.openapi({
type: "boolean",
description: "Filter by server admin status"
})
});
@@ -177,7 +186,8 @@ export async function adminListUsers(
sort_by,
order,
idp_id,
two_factor: twoFactorFilter
two_factor: twoFactorFilter,
server_admin: serverAdminFilter
} = parsedQuery.data;
if (typeof idp_id === "number") {
@@ -233,6 +243,10 @@ export async function adminListUsers(
}
}
if (typeof serverAdminFilter === "boolean") {
conditions.push(eq(users.serverAdmin, serverAdminFilter));
}
const whereClause = and(...conditions);
const countQuery = db.$count(