let session = require('../../database/models/session');

let isAuthorizedForRoute = (req, res, next) => {
  session.getSession(req.cookies.session.id)
  .then((session) => {
    if (session.hash === req.cookies.session.hash &&
        session.houseId === req.cookies.session.houseId &&
        session.userId === req.cookies.session.userId) {
      next();
    } else {
      res.clearCookie('session');
      res.redirect(401, '/login');
    }
  });

};

module.exports = isAuthorizedForRoute;

let session = require('../../database/models/session');

let isAuthorizedForRoute = (req, res, next) => {
  session.getSession(req.cookie.id)
  .then((session) => {
    console.log(session);
  });

};

module.exports = isAuthorizedForRoute;

--- 
+++ 
@@ -1,9 +1,16 @@
 let session = require('../../database/models/session');
 
 let isAuthorizedForRoute = (req, res, next) => {
-  session.getSession(req.cookie.id)
+  session.getSession(req.cookies.session.id)
   .then((session) => {
-    console.log(session);
+    if (session.hash === req.cookies.session.hash &&
+        session.houseId === req.cookies.session.houseId &&
+        session.userId === req.cookies.session.userId) {
+      next();
+    } else {
+      res.clearCookie('session');
+      res.redirect(401, '/login');
+    }
   });
 
 };
Add authorized route checking middleware

NOTE: Not integrated yet, will be integrated once session adding middleware is in place
