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

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

};

module.exports = isAuthorizedForRoute;

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;

Add authorized route checking middleware
Add authorized route checking middleware

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