Fix director role access when no groups are assigned

Resolve issue where directors without assigned groups were returned all groups, by returning an empty array instead.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 28b81ac1-a55f-409c-b6a9-88ad420d8a9a
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/28b81ac1-a55f-409c-b6a9-88ad420d8a9a/6PoDWd4
This commit is contained in:
michaelschal committed 2025-09-03 09:05:19 +00:00
1 parent 90cec2124f
commit 1fc793d710
1 file changed
+8
+8
View File
@@ -102,6 +102,14 @@ export async function registerRoutes(app: Express): Promise<Server> {
filteredGroupsCount: userGroups.length,
groups: userGroups.map((g: any) => ({ id: g.id, name: g.name }))
});
// CRITICAL: Si un directeur n'a aucun groupe assigné, retourner un tableau vide
// au lieu de tous les groupes
if (user.role === 'directeur' && userGroups.length === 0) {
console.log('🚨 [CRITICAL] Directeur has no assigned groups - returning empty array');
return res.json([]);
}
res.json(userGroups);
}
} catch (error) {