ソースを参照

Bug fix: logging in stored the merchant rather than its id to session.

Lee Morgan 5 年 前
コミット
193772dbaa
2 ファイル変更4 行追加1 行削除
  1. 2 1
      controllers/otherData.js
  2. 2 0
      controllers/renderer.js

+ 2 - 1
controllers/otherData.js

@@ -53,7 +53,8 @@ module.exports = {
                                 await response[0].save();
                             }
 
-                            req.session.merchant = (response[1] === null) ? await Merchant.findOne({_id: response[0].merchants[0]}) : response[1];
+                            let gotMerchant = (response[1] === null) ? await Merchant.findOne({_id: response[0].merchants[0]}) : response[1];
+                            req.session.merchant = gotMerchant._id;
                             req.session.owner = response[0].session.sessionId;
                             return res.redirect("/dashboard");
                         }else{

+ 2 - 0
controllers/renderer.js

@@ -65,6 +65,7 @@ module.exports = {
                     let latest = null;
                     if(transactions.length === 0){
                         let latestTransaction = await Transaction.find({merchant: res.locals.merchant._id}).sort({date: -1}).limit(1);
+                        console.log(latestTransaction);
                         if(latestTransaction.length > 0) latest = new Date(latest[0].date);
                     }else{
                         latest = new Date(transactions[0].date);
@@ -128,6 +129,7 @@ module.exports = {
                 return res.render("dashboardPage/dashboard", {owner: res.locals.owner, merchant: res.locals.merchant, transactions: transactions});
             })
             .catch((err)=>{
+                console.log(err);
                 req.session.error = "ERROR: UNABLE TO RETRIEVE DATA";
                 return res.redirect("/");
             });