Show assigned groups for users in the system

Update the API to include user groups in the user data endpoint and add frontend logging for user details.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 31f9bd88-0285-4787-81b3-31ceeea5a08b
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/31f9bd88-0285-4787-81b3-31ceeea5a08b/7ff921U
This commit is contained in:
michaelschal committed 2025-08-14 11:52:52 +00:00
1 parent 4d118328de
commit cd436070cd
2 files changed
+34 -11

No files matched your search

@@ -68,6 +68,16 @@ export function CustomerOrderForm({
const { user } = useAuthUnified();
const { selectedStoreId } = useStore();
// DEBUG: Log user data to see what we actually receive
console.log("🔍 FRONTEND USER DEBUG:", {
user: user,
userRole: user?.role,
userGroups: user?.userGroups,
userGroupsType: typeof user?.userGroups,
userGroupsLength: user?.userGroups?.length,
fullUserObject: JSON.stringify(user, null, 2)
});
// Fetch groups for store selection
const { data: groups = [] } = useQuery<Group[]>({
queryKey: ['/api/groups'],
+24 -11
View File
@@ -188,20 +188,33 @@ export function setupLocalAuth(app: Express) {
app.get("/api/logout", logoutHandler);
// Get current user
app.get("/api/user", (req, res) => {
app.get("/api/user", async (req, res) => {
if (!req.isAuthenticated()) {
return res.status(401).json({ message: "Non authentifié" });
}
const user = req.user as SelectUser;
res.json({
id: user.id,
username: user.username,
email: user.email,
firstName: user.firstName,
lastName: user.lastName,
role: user.role,
passwordChanged: user.passwordChanged
});
try {
const userId = (req.user as SelectUser).id;
const userWithGroups = await storage.getUserWithGroups(userId);
if (!userWithGroups) {
return res.status(404).json({ message: "Utilisateur non trouvé" });
}
res.json({
id: userWithGroups.id,
username: userWithGroups.username,
email: userWithGroups.email,
firstName: userWithGroups.firstName,
lastName: userWithGroups.lastName,
role: userWithGroups.role,
passwordChanged: userWithGroups.passwordChanged,
userGroups: userWithGroups.userGroups || []
});
} catch (error) {
console.error("Error fetching user with groups:", error);
res.status(500).json({ message: "Erreur lors de la récupération des données utilisateur" });
}
});
// Check if default credentials should be shown