mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-23 15:08:22 +02:00
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:
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 { user } = useAuthUnified();
|
||||||
const { selectedStoreId } = useStore();
|
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
|
// Fetch groups for store selection
|
||||||
const { data: groups = [] } = useQuery<Group[]>({
|
const { data: groups = [] } = useQuery<Group[]>({
|
||||||
queryKey: ['/api/groups'],
|
queryKey: ['/api/groups'],
|
||||||
|
|||||||
+24
-11
@@ -188,20 +188,33 @@ export function setupLocalAuth(app: Express) {
|
|||||||
app.get("/api/logout", logoutHandler);
|
app.get("/api/logout", logoutHandler);
|
||||||
|
|
||||||
// Get current user
|
// Get current user
|
||||||
app.get("/api/user", (req, res) => {
|
app.get("/api/user", async (req, res) => {
|
||||||
if (!req.isAuthenticated()) {
|
if (!req.isAuthenticated()) {
|
||||||
return res.status(401).json({ message: "Non authentifié" });
|
return res.status(401).json({ message: "Non authentifié" });
|
||||||
}
|
}
|
||||||
const user = req.user as SelectUser;
|
|
||||||
res.json({
|
try {
|
||||||
id: user.id,
|
const userId = (req.user as SelectUser).id;
|
||||||
username: user.username,
|
const userWithGroups = await storage.getUserWithGroups(userId);
|
||||||
email: user.email,
|
|
||||||
firstName: user.firstName,
|
if (!userWithGroups) {
|
||||||
lastName: user.lastName,
|
return res.status(404).json({ message: "Utilisateur non trouvé" });
|
||||||
role: user.role,
|
}
|
||||||
passwordChanged: user.passwordChanged
|
|
||||||
});
|
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
|
// Check if default credentials should be shown
|
||||||
|
|||||||
Reference in new issue
Block a user