Improve user data retrieval to include roles and group assignments

Update the API endpoint for fetching users to include their associated roles and group assignments, enhancing the detail of user data returned.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: a8a78c07-e900-425c-a577-5b4c5894379d
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/a8a78c07-e900-425c-a577-5b4c5894379d/fwSlq3W
This commit is contained in:
michaelschal committed 2025-08-11 19:57:01 +00:00
1 parent 07b848b127
commit 22bdbff494
2 files changed
+8 -2

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

+8 -2
View File
@@ -862,11 +862,17 @@ export async function registerRoutes(app: Express): Promise<Server> {
return res.status(403).json({ message: "Access denied" });
}
console.log('🔍 GET /api/users - Fetching users with roles and groups');
// Get all users with groups for admin
const allUsers = await storage.getUsers();
const allUsers = await storage.getUsersWithRolesAndGroups();
const safeUsers = Array.isArray(allUsers) ? allUsers : [];
console.log('🔐 API /api/users - Returning:', { isArray: Array.isArray(safeUsers), length: safeUsers.length });
console.log('🔐 API /api/users - Returning:', {
isArray: Array.isArray(safeUsers),
length: safeUsers.length,
firstUserGroups: safeUsers.length > 0 ? safeUsers[0].userGroups?.length || 0 : 0
});
res.json(safeUsers);
} catch (error) {
console.error("Error fetching users:", error);