https://mindflip.github.io/javascript/node.js/nodejs_passport/ Use middleware with passport.js to check whether user is authenticated or not.