Skip to content

Commit

Permalink
Ensure all users' emails are fetched from Keycloak
Browse files Browse the repository at this point in the history
  • Loading branch information
danieladugyan committed Oct 18, 2024
1 parent eba8333 commit a3a8e78
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/server/keycloak/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,14 @@ async function getManyUserEmails(
const client = await connect();
const userEmails = new Map<string, string>();

(await client.users.find({ username: "" })).forEach((user) => {
// Fetch all users from Keycloak
// We can only fetch a limited amount of users at a time
const users = [];
do {
users.push(...(await client.users.find({ max: 500, first: users.length })));
} while (users.length % 500 === 0);

users.forEach((user) => {
const { username, email } = user;
if (!username || !email) return;

Expand Down

0 comments on commit a3a8e78

Please sign in to comment.