mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-12 09:47:54 +02:00
Merge pull request #35 from R0m1k3/1.1
Enable employees to create and edit customer orders with correct perm…
This commit is contained in:
5 files changed
+12
-5
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 310 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 406 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 389 KiB |
+12
-2
@@ -1940,12 +1940,17 @@ RÉSUMÉ DU SCAN
|
||||
return res.status(404).json({ message: "User not found" });
|
||||
}
|
||||
|
||||
// Check permissions for customer-orders create
|
||||
if (!hasPermission(user.role, 'customer-orders', 'create')) {
|
||||
return res.status(403).json({ message: "Insufficient permissions to create customer orders" });
|
||||
}
|
||||
|
||||
const data = insertCustomerOrderSchema.parse(req.body);
|
||||
console.log("Parsed data:", data);
|
||||
|
||||
// Check if user has access to the specified group
|
||||
if (user.role !== 'admin') {
|
||||
const userGroupIds = user.userGroups.map(ug => ug.groupId);
|
||||
const userGroupIds = user.userGroups?.map((ug: any) => ug.groupId) || [];
|
||||
if (!userGroupIds.includes(data.groupId)) {
|
||||
return res.status(403).json({ message: "Access denied to this group" });
|
||||
}
|
||||
@@ -1980,8 +1985,13 @@ RÉSUMÉ DU SCAN
|
||||
return res.status(404).json({ message: "Customer order not found" });
|
||||
}
|
||||
|
||||
// Check edit permissions
|
||||
if (!hasPermission(user.role, 'customer-orders', 'edit')) {
|
||||
return res.status(403).json({ message: "Insufficient permissions to edit customer orders" });
|
||||
}
|
||||
|
||||
if (user.role !== 'admin') {
|
||||
const userGroupIds = user.userGroups.map(ug => ug.groupId);
|
||||
const userGroupIds = user.userGroups?.map((ug: any) => ug.groupId) || [];
|
||||
if (!userGroupIds.includes(existingOrder.groupId)) {
|
||||
return res.status(403).json({ message: "Access denied" });
|
||||
}
|
||||
|
||||
@@ -500,9 +500,6 @@ export type Task = typeof tasks.$inferSelect;
|
||||
export type InsertTask = z.infer<typeof insertTaskSchema>;
|
||||
|
||||
// Complex types with relations
|
||||
export type UserWithGroups = User & {
|
||||
groups: Group[];
|
||||
};
|
||||
|
||||
export type OrderWithRelations = Order & {
|
||||
supplier: Supplier;
|
||||
|
||||
Reference in new issue
Block a user