Fix issue where user groups were not correctly assigned for product creation

Correct the user API endpoint to include user groups in the response, resolving an issue where products were created with incorrect or default group assignments due to missing group data.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: b163d4c0-de5e-4f4e-a9c0-aed4c7049718
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/b163d4c0-de5e-4f4e-a9c0-aed4c7049718/KQQafdY
This commit is contained in:
michaelschal committed 2025-08-12 15:28:48 +00:00
1 parent 4ede8303ab
commit a2110a84b4
3 files changed
+77 -79

No files matched your search

+13 -1
View File
@@ -232,6 +232,17 @@ export function setupLocalAuth(app: Express) {
// Get current user
app.get("/api/user", (req: any, res) => {
if (req.isAuthenticated && req.isAuthenticated()) {
console.log("🔍 PRODUCTION /api/user - req.user:", {
id: req.user.id,
role: req.user.role,
hasUserGroups: !!req.user.userGroups,
userGroupsLength: req.user.userGroups?.length,
userGroups: req.user.userGroups?.map((ug: any) => ({
groupId: ug.groupId || ug.group?.id,
groupName: ug.group?.name
}))
});
res.json({
id: req.user.id,
username: req.user.username,
@@ -239,7 +250,8 @@ export function setupLocalAuth(app: Express) {
firstName: req.user.firstName,
lastName: req.user.lastName,
role: req.user.role,
passwordChanged: req.user.passwordChanged
passwordChanged: req.user.passwordChanged,
userGroups: req.user.userGroups || [] // ✅ AJOUT DES USER GROUPS !
});
} else {
res.status(401).json({ message: "Not authenticated" });