mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-16 11:46:21 +02:00
Fix issue with incorrect store assignment for customer orders and DLC products
Implement enhanced logging and an alternative group ID access pattern in server routes to resolve an issue where customer orders and DLC products were incorrectly assigned to the default store instead of the user's designated store, particularly in production environments. 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/N0tzMbW
This commit is contained in:
1 parent
8939b40bcc
commit
39bae75d82
2 files changed
+101
-3
No files matched your search
+35
-3
@@ -1952,10 +1952,26 @@ RÉSUMÉ DU SCAN
|
||||
|
||||
// Fix groupId BEFORE validation - use user's assigned group or fallback
|
||||
let finalGroupId = req.body.groupId;
|
||||
|
||||
console.log("🔍 Customer Order GroupId Debug Production:", {
|
||||
originalGroupId: req.body.groupId,
|
||||
userGroups: user.userGroups?.map(ug => ({
|
||||
groupId: ug.groupId,
|
||||
groupName: ug.group?.name,
|
||||
rawGroup: ug.group
|
||||
})),
|
||||
userGroupsLength: user.userGroups?.length,
|
||||
firstUserGroup: user.userGroups?.[0]
|
||||
});
|
||||
|
||||
if (!finalGroupId || finalGroupId === undefined || finalGroupId === null || finalGroupId === '') {
|
||||
if (user.userGroups?.[0]?.groupId) {
|
||||
finalGroupId = user.userGroups[0].groupId;
|
||||
console.log("🔧 Customer Order Backend Fix: Using user's assigned group:", finalGroupId);
|
||||
} else if (user.userGroups?.[0]?.group?.id) {
|
||||
// Alternative access pattern for production
|
||||
finalGroupId = user.userGroups[0].group.id;
|
||||
console.log("🔧 Customer Order Backend Fix: Using user's group.id:", finalGroupId);
|
||||
} else {
|
||||
finalGroupId = 1; // Emergency fallback
|
||||
console.log("🚨 Customer Order Backend Fix: Using emergency fallback groupId:", finalGroupId);
|
||||
@@ -2355,13 +2371,29 @@ RÉSUMÉ DU SCAN
|
||||
|
||||
// Fix groupId if missing - use user's assigned group or fallback
|
||||
let finalGroupId = req.body.groupId;
|
||||
if (!finalGroupId) {
|
||||
|
||||
console.log("🔍 DLC GroupId Debug Production:", {
|
||||
originalGroupId: req.body.groupId,
|
||||
userGroups: user.userGroups?.map(ug => ({
|
||||
groupId: ug.groupId,
|
||||
groupName: ug.group?.name,
|
||||
rawGroup: ug.group
|
||||
})),
|
||||
userGroupsLength: user.userGroups?.length,
|
||||
firstUserGroup: user.userGroups?.[0]
|
||||
});
|
||||
|
||||
if (!finalGroupId || finalGroupId === undefined || finalGroupId === null) {
|
||||
if (user.userGroups?.[0]?.groupId) {
|
||||
finalGroupId = user.userGroups[0].groupId;
|
||||
console.log("🔧 Backend Fix: Using user's assigned group:", finalGroupId);
|
||||
console.log("🔧 DLC Backend Fix: Using user's assigned group:", finalGroupId);
|
||||
} else if (user.userGroups?.[0]?.group?.id) {
|
||||
// Alternative access pattern for production
|
||||
finalGroupId = user.userGroups[0].group.id;
|
||||
console.log("🔧 DLC Backend Fix: Using user's group.id:", finalGroupId);
|
||||
} else {
|
||||
finalGroupId = 1; // Emergency fallback
|
||||
console.log("🚨 Backend Fix: Using emergency fallback groupId:", finalGroupId);
|
||||
console.log("🚨 DLC Backend Fix: Using emergency fallback groupId:", finalGroupId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user