Просмотр исходного кода

Update merchant ingredient updating to work with new session id.

Lee Morgan 5 лет назад
Родитель
Сommit
c0ad4a2515
2 измененных файлов с 3 добавлено и 7 удалено
  1. 2 6
      controllers/merchantData.js
  2. 1 1
      routes.js

+ 2 - 6
controllers/merchantData.js

@@ -229,15 +229,11 @@ module.exports = {
     }]
     */
     updateMerchantIngredient: function(req, res){
-        if(!req.session.user){
-            req.session.error = "MUST BE LOGGED IN TO DO THAT";
-            return res.redirect("/");
-        }
-
         let adjustments = [];
         let changedIngredients = [];
-        Merchant.findOne({_id: req.session.user})
+        res.locals.merchant
             .populate("inventory.ingredient")
+            .execPopulate()
             .then((merchant)=>{
                 for(let i = 0; i < req.body.length; i++){
                     let updateIngredient;

+ 1 - 1
routes.js

@@ -23,7 +23,7 @@ module.exports = function(app){
     app.post("/merchant/create/none", merchantData.createMerchantNone);
     app.get("/merchant/create/clover", merchantData.createMerchantClover);
     app.get("/merchant/create/square", merchantData.createMerchantSquare);
-    app.put("/merchant/ingredients/update", merchantData.updateMerchantIngredient); //also updates some data in ingredients
+    app.put("/merchant/ingredients/update", session, merchantData.updateMerchantIngredient); //also updates some data in ingredients
     app.post("/merchant/password", merchantData.updatePassword);
 
     //Ingredients