Multi tenant DB, registratie per huishouden V1.2

This commit is contained in:
2026-08-09 19:50:53 +02:00
parent 1f9fd73026
commit c37b8956d4
15 changed files with 148 additions and 96 deletions
+5 -3
View File
@@ -25,8 +25,8 @@ class ShoppingListController {
res.locals.title = list.name;
res.render("lists/show", {
list,
items: ShoppingListRepository.getItems(list.id),
products: ProductRepository.getAll(),
items: ShoppingListRepository.getItems(list.id, req.user.household_id),
products: ProductRepository.getAll(req.user.household_id),
user: req.user
});
}
@@ -35,7 +35,9 @@ class ShoppingListController {
const list = ShoppingListRepository.findById(req.params.id, req.user.household_id);
const productId = Number.parseInt(req.body.product_id, 10);
const amount = Number.parseFloat(req.body.amount || "1");
const product = Number.isInteger(productId) ? ProductRepository.findById(productId) : null;
const product = Number.isInteger(productId)
? ProductRepository.findById(productId, req.user.household_id)
: null;
if (!list || !product || !Number.isFinite(amount) || amount <= 0) {
req.flash("error", "Ongeldig product of ongeldige hoeveelheid");
return res.redirect(`/lists/${req.params.id}`);