NODE.JS with express website routing error - node.js

I am writing a website in node.js and express. At the current moment if i run the website the login controller is loaded every time and it just loads forever.
I don't want the login controller to be loaded when i load the page. I need to to be loaded when i click on my button login.
This is my Router.js
module.exports = function(app) {
app.get('/login/:username/:password', function(req, res) {
var login = require('../controllers/login');
login.userLogin
});
app.get('/', function(req, res, next) {
res.render('index', {
title: 'Trace User Login'
});
});
}
This is my jade page
extends layout
block content
div#login
label#lblInfo Please enter your username and password.
input#txtUsername.form-control.login(placeholder='Username', type='text')
input#txtPassword.form-control.login(placeholder='Password', type='password')
a#btnLogin.btn.btn-danger.btn-lg(href='#') Login
block endContent
div.footer
p#dev Developed by :
a.redtextheadingsmall(href="http://www.verishare.co.za/", target="_blank") VeriShare
p Telephone: +27 (18) 294 1000 Fax: +27 (18) 294 3880 Email:
a.redtextheadingsmall(href="mailto:tracesupport#vccb.co.za") tracesupport#vccb.co.za
p We recommend that you view this website with: MS IE 10+ or Google Chrome 20.0+ or Mozilla 20.0+
p#copy Copyright © 2014 .. All Rights Reserved.
How do i go about getting the login module to only load once i click on the login button. At the current moment the page is not even rendering as it is just stuck in loading my login Controller
console.log('Inside controller');
exports.userLogin = function(request, respond){
var Connection = require('tedious').Connection;
var Request = require('tedious').Request;
var config = {
userName: 'username',
password: 'password',
server: 'localhost',
options: {
instanceName: 'instance',
database: 'tempdb'
}
};
var connection = new Connection(config);
connection.on('connect', function(err) {
if (err)
console.log(err);
else
var userName = request.params.username;
var password = request.params.password;
loginRequest(userName,password);
});
};
function loginRequest(Username,Password) {
request = new Request("sp_WT_ValidateUser", function(err, rowCount) {
if (err) {
console.log(err);
} else {
console.log(rowCount + ' rows');
}
});
request.addParameter('UserName', TYPES.VarChar, Username);
request.addParameter('Password', TYPES.VarChar, Password);
request.addOutputParameter('InvalidPasswordCounter', TYPES.VarChar);
request.on('row', function(columns) {
columns.forEach(function(column) {
console.dir(column);
});
console.log('');
});
connection.execSql(request);
}

This seemed to fix my problems
var router = require('express').Router();
var login = require('../controllers/login');
router.post('/login', login.userLogin);
router.get('/', function(req, res, next) {
res.render('index', {
title: 'Trace User Login'
});
});
module.exports = router;

Related

Nodemailer sends blank emails when using EJS templates

The following code in my server successfully sends an email when a submit button is hit on the splash page. I am pulling a list that is input from the user coming from mongoDB. When I call console.log on the variable data it shows that everything is in it's right place. This is what I get in the terminal, followed by the code itself. The problem is that everything looks correct except the emails are blank in the body. Subject is there but everything that the console is printing out in html through ejs is gone. Terminal says its there but when I receive email, blank...
DB CONNECTION SUCCESSFUL
Monday, March 21
Server is Flying
html data ======================> <body>
<h1></h1>
<ul>
<li>Welcome to Fedex Staffing Beta!</li>
<li>Geoffrey Singfred</li>
<li>Elizabeth Holmes</li>
<li>Diana Ross</li>
<li>Frank</li>
</ul>
</body>
[Error: 31772:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:
] {
library: 'SSL routines',
function: 'ssl3_get_record',
reason: 'wrong version number',
code: 'ESOCKET',
command: 'CONN'
const express = require("express");
const ejs = require("ejs");
const bodyParser = require("body-parser");
const mongoose = require("mongoose");
const _ = require("lodash");
const date = require(__dirname + "/date.js");
const nodemailer = require("nodemailer");
// MONGO CONNECTION //
// This is the connection to the database. 27017 is the port mongo chooses by default
mongoose.connect("mongodb+srv://user-admin:password#cluster0.zrsn0.mongodb.net/cluster0?retryWrites=true&w=majority")
console.log("DB CONNECTION SUCCESSFUL")
// EE TABLE //
// This is the employee default schema. Just a name.
const itemsSchema = new mongoose.Schema ({
item: String,
});
const listSchema = new mongoose.Schema({
name: String,
items: [itemsSchema]
});
// This initializes a new schema or what Mongo calls a collection. Each collection
// is essentially the equivalent of a table in SQL
const Item = mongoose.model("Item", itemsSchema);
const List = mongoose.model("List", listSchema);
// Write now the app starts with items by default. These are them. They can be deleted
// easily by checking the box in the app. I'm sure there is a better way to do this.
const item1 = new Item({
item: "Welcome to Fedex Staffing!",
});
// Just a default list I use to call when a new page is created.
const defaultItems = [item1];
////// BEGIN APP //////
// Intitalize date
const day = date.getDate();
// Initialize express
const app = express();
// Initialize ejs
app.set("view engine", "ejs");
app.use(express.static("public"));
// Intialize body parser.
app.use(bodyParser.urlencoded({
extended: true
}));
// MAIN PAGE //
// A GET call to retrieve all current items in the database, if there are less
// than zero then it adds back the default items listed below
app.get("/", function(req, res) {
Item.find({}, function(err, foundItems){
if (foundItems.length === 0){
Item.insertMany(defaultItems, function(err){
if (err) {
console.log(err);
} else {
console.log("Items successfully added.");
}
});
res.redirect("/");
} else {
res.render("list", {listTitle: day,newListItems: foundItems});
};
});
});
// A POST call to add items to the list and the database
app.post("/", function(req, res) {
const itemName = req.body.newItem;
const listName = req.body.list;
const item = new Item({
item: itemName
});
if (listName === day){
item.save();
res.redirect("/");
} else {
List.findOne({name: listName}, function(err, foundList){
foundList.items.push(item);
foundList.save();
res.redirect("/" + listName);
});
};
});
// This delete route for when you check a checkbox, it then deletes the item.
app.post("/delete", function(req, res){
const checkedItemId = req.body.checkbox;
const listName = req.body.listName;
if (listName === day){
Item.findByIdAndRemove(checkedItemId, function(err){
if(!err) {
console.log("Successfully deleted checked item")
res.redirect("/");
};
});
} else {
List.findOneAndUpdate({name: listName}, {$pull: {items: {_id: checkedItemId}}}, function(err, foundList){
if(!err){
res.redirect("/" + listName);
};
});
};
});
app.post("/send", function(req, res){
const title = req.body.customName
var transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 666,
secure: true, // use SSL
auth: {
user: "***********#hellmail.com",
pass: "*********"
}
});
Item.find({}, function(err, foundItems){
const data = ejs.renderFile(__dirname + "/views/emailtemp.ejs", {newListItems: foundItems, listTitle: title}, function (err, data) {
if (err) {
console.log(err);
} else {
var mainOptions = {
from: '"Jesus"*************#gmail.com',
to: "*********#gmail.com",
subject: 'Hello, world',
html: data
};
console.log("html data ======================>", mainOptions.html);
transporter.sendMail(mainOptions, function (err, info) {
if (err) {
console.log(err);
} else {
console.log('Message sent: ' + info.response);
}
});
}
});
});
});
console.log(day)
app.listen(process.env.PORT || 3000, function() {
console.log("Server is Flying");
});
```
So I answered my own question for the first time. In my code, when I initialize the transporter, I have the handshake connection on secure set to 'true'. I did some reading and found that there is something going on there not matching the handshake. Without going into a ton of detail, I changed it to 'false', instead of 'true' and for the first time, the app works perfectly.

Cognito authenticating entire EC2 instance... or so it it seems?

It appears as though when I sign into my application, it is storing the credentials locally on the EC2 server. I've quadruple checked my code and I can't figure out what the deal is. If KEVIN signs in from any device, the next user to sign in, or if someone refreshes their page they end up signed in as KEVIN. I am including all code that could potentially be involved in the issue. Outside of this problem, all of my interaction with cognito works great; no errors & no problems. Any help would be greatly appreciated. I am using Node.js, Express, AWS, and Websockets on my EC2 Instance.
// Accessed from server for route authentication before page render or redirection
const AmazonCognitoIdentity = require('amazon-cognito-identity-js');
module.exports = {
ensureAuthenticated: function(req, res, next) {
let data = { UserPoolId : 'us-east-1_7xUGRJPKq',
ClientId : '6glign6b34c806osfhnik18cb3'
};
let userPool = new AmazonCognitoIdentity.CognitoUserPool(data);
let cognitoUser = userPool.getCurrentUser();
console.log(`ensuring authentication....`);
console.log(cognitoUser);
if (cognitoUser === null) {
req.flash('error_msg', 'Please log in');
res.redirect('/login');
} else {
cognitoUser.getSession((err, session) => {
if (err) {
console.log(err);
} else {
next();
}
});
}
},
};
// Routes where I am seeing the problem
const express = require('express');
const router = express.Router();
const AmazonCognitoIdentity = require('amazon-cognito-identity-js');
const { ensureAuthenticated } = require('../config/auth.js');
router.get('/', (req, res) => {
res.redirect('/dashboard');
});
router.get('/dashboard', ensureAuthenticated, (req, res) => {
res.render('dashboard', {
layout: './layouts/dashboard-layout.ejs'
});
});
// Login authentication
router.post('/login', (req, res) => {
const loginDetails = {
Username: req.body.email,
Password: req.body.password
}
const authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails(loginDetails);
const userDetails = {
Username: req.body.email,
Pool: userPool
}
const cognitoUser = new AmazonCognitoIdentity.CognitoUser(userDetails);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: data => {
cognitoUser.getUserAttributes(function(err, result) {
if (err) {
console.log(err);
return;
} else {
console.log('LOGIN RESULTS')
console.log(result[0].Value.toString());
let userId = result[0].Value.toString();
let userCity = result[2].Value.toString();
console.log(userId);
console.log(userCity);
res.redirect(`/dashboard/${userCity}/${userId}/`)
};
});
},
onFailure: err => {
req.flash('error_msg', 'Invalid Credentials');
console.error(err);
res.redirect('/login');
}
})
});
Thank You!
UPDATE 10/21/19: Removed function that doesn't apply to the issue.
Also do not seem to have any JWT in local storage:
Click Here for image

NodeJS, getting username of logged in user within route

I am getting in to NodeJS and have followed some video tutorials for making stuff, to understand NodeJS and Express. It turned more in to copying as little were explained, so tried to make my own thing using what I learned and so on.
Making a simple login function with PassportJS, ExpressJs and Mongoose.
The login and stuff works, and I can get the username of the currently logged in user and display it if I define it within the main app.js using this:
app.get("/stuff", (req,res) => {
res.render("stuff.html", {username:req.user.username});
});
Now if I want to make nice and structured by using router, I cannot get it to work. It throws error saying username is undefined, making page unable to render. The router itself works if I don't pass any variable or use variables I know will work (e.g. var x = "Hello"; res.render … {msg:x});).
Part of the app.js that handle routes:
var stuff = require("./routes/stuff");
app.use("/stuff", stuff);
module.exports.app;
I've tried to cont x = require("…") basically everything that is in the app.js in this stuff.js file, but to no avail, so removed everything but express + routes to get fresh start.
How do I pass the username that is working in app.js in to the routed file? Preferably make it automatically do to every page if possible, using app.get("*")… or something.
Entire stuff.js:
/* Routes */
const express = require("express");
const router = express.Router();
/* Stuff */
router.get("/", function(req, res, next) {
res.render("stuff.html", {username:req.user.username});
console.log(req.user.username);
next();
});
/* Bottom */
module.exports = router;
Login section of app.js:
app.post('/login',
passport.authenticate('local',
{
successRedirect: '/dashboard',
failureRedirect: '/login',
failureFlash: 'Wrong login'
}
), function(req,res) {
console.log("Hello " + req.user.username);
});
passport.serializeUser(function(user,done) {
done(null, user.id);
});
passport.deserializeUser(function(id,done) {
User.getUserById(id, function(err, user) {
done(err,user);
});
});
passport.use(new LocalStrategy(function(username,password,callback) {
User.getUserByUsername(username, function(err,user) {
if(err) throw err;
if(!user) {
return callback(null, false, {msg: "shit"});
}
User.comparePassword(password, user.password, function(err,isMatch) {
if(err) return callback(err);
if(isMatch) {
return callback(null, user);
} else {
return callback(null, false, {msg:"Something"});
}
});
});
}));
The users.js file for handling registering new users, if that's relevant:
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost/users");
const db = mongoose.connection;
mongoose.Promise = global.Promise;
const bcrypt = require("bcryptjs");
/* Data schema */
const userSchema = mongoose.Schema({
name: {
type: String
},
username: {
type: String,
index: true
},
password: {
type: String
},
email: {
type: String
}
});
var User = module.exports = mongoose.model("User", userSchema);
module.exports.createUser = function(newUser, callback) {
bcrypt.genSalt(10, function(err, salt) {
bcrypt.hash(newUser.password, salt, function(err, hash) {
newUser.password = hash;
newUser.save(callback);
});
});
}
module.exports.getUserById = function(id, callback) {
User.findById(id, callback);
}
module.exports.getUserByUsername = function(username, callback) {
var query = {username: username};
User.findOne(query, callback);
}
module.exports.comparePassword = function(testPw, hash, callback) {
bcrypt.compare(testPw, hash, function(err,isMatch) {
callback(null,isMatch);
});
}
As far as I understand you are trying to pass your username to the preferably every file including your router file. What I do for this to use middleware in app.js to pass every page. Or you can simply implement passport implementation in the other page as well which could be useless i guess.
app.use(function(req,res,next){
res.locals.currentUser=req.user
next()
}
Then, you can use use your currentUser in every page when you try to render.
I encountered the same issue, probably after following the same tutorials...
I found that the function you need in the app.js is:
app.get('*', function(req, res,next){
res.locals.user = req.user || null;
next();
})
it should be in the app.js already. Now, in all of the other page you should be able to use req.user.username

Redirecting POST to GET after Database Addition

I am using Mongoose and Express.js .
My Post request looks like this :
$('#update').on('click', function() {
var uname = $('#username').val();
var name = $('#name').val();
var json = {
user_name: name,
user_username: uname,
};
$.post("/saveprofile", json, function(data, error, xhr) {
if(!err)
window.location.href = "/feed";
});
});
This is how I'm handling the request :
app.post('/saveprofile', isLoggedIn, function(req, res) {
var username = req.body.user_username;
var uname = req.body.user_name;
User.findOne({$or:[{"facebook.email":req.user.facebook.email},{"local.email":req.user.local.email}]}, function (err, user){
user.name = uname;
user.username=username;
user.save();
res.send({redirect: '/feed'});
})
});
My documents get added into the db successfully but what I want is, when that happens it should redirect to a new page /feed . The above snippets mention 2 methods I've tried. But I've got no result . It doesn't redirect !
Edit:
Testing with exception handling gives undefined
app.post('/saveprofile', isLoggedIn, function(req, res) {
var username = req.body.user_username;
var uname = req.body.user_name;
try{
User.findOne({$or:[{"facebook.email":req.user.facebook.email},{"local.email":req.user.local.email}]}, function (err, user){
user.name = uname;
user.username=username;
user.save();
res.redirect("http://stackoverflow.com")
});
}
catch(ex){
console.log(ex) ;
}
});
Edit 2 :
I tried a sample request ...even it doesn't seem to redirect !
app.post('/test', isLoggedIn, function(req,res){
res.redirect("http://www.stackoverflow.com")
})
You can't make a redirection after an AJAX. You need to do it with Javascript.
So here is how we can do it,
Post request :
$('#update').on('click', function() {
var uname = $('#username').val();
var name = $('#name').val();
var json = {
user_name: name,
user_username: uname,
};
$.post("/saveprofile", json, function(data, err, xhr) {
if(!err)
window.location.href = data.redirect;
});
});
Server
app.post('/saveprofile', isLoggedIn, function(req, res) {
var username = req.body.user_username;
var uname = req.body.user_name;
User.findOne({$or:[{"facebook.email":req.user.facebook.email},{"local.email":req.user.local.email}]}, function (err, user){
user.name = uname;
user.username=username;
user.save(function(err){
if(!err)
res.send({redirect: '/feed'});
});
})
});
Link to Original Answer
Try res.redirect() instead :
res.redirect("/feed");

Problems in integration of everyauth example with a simple login application

I am trying to use everyauth example for logging in with facebook. I printed the everyauth debug message which kind of shows that the authentication is performed successfully. However, the everyauth.loggedIn variable is not set. I am not sure why. I am actually having my code like this
I have a page which has the link to auth/facebook. When the user clicks on that link, the user is sent for facebook authentication and everything completes. However, when I check for everyauth.loggedIn it is always undefined
if(everyauth.loggedIn) {
console.log('The user has logged in');
}
The above is something that I am trying to check when there is request at the '/' url. This is after the facebook authentication has been performed. However, it always comes out to be undefined. Could it be because of local, global variable issue. I am passing the everyauth variable to several modules. Any suggestions will be appreciated
app.js(sets up the express application)
var exp = require('express');
var app = exp.createServer();
var conf = require('/path/example/conf')
var everyauth = require('everyauth');
everyauth.debug = true;
var usersById = {};
var nextUserId = 0;
function addUser (source, sourceUser) {
var user;
user = usersById[++nextUserId] = {id: nextUserId};
user[source] = sourceUser;
return user;
}
var usersByFbId = {};
var usersByTwitId = {};
everyauth.everymodule
.findUserById( function (id, callback) {
callback(null, usersById[id]);
});
everyauth
.facebook
.appId(conf.fb.appId)
.appSecret(conf.fb.appSecret)
.findOrCreateUser( function (session, accessToken, accessTokenExtra, fbUserMetadata) {
return usersByFbId[fbUserMetadata.id] || (usersByFbId[fbUserMetadata.id] = addUser('facebook', fbUserMetadata));;
})
.redirectPath('/');
everyauth
.twitter
.consumerKey(conf.twit.consumerKey)
.consumerSecret(conf.twit.consumerSecret)
.findOrCreateUser( function (sess, accessToken, accessSecret, twitUser) {
return usersByTwitId[twitUser.id] || (usersByTwitId[twitUser.id] = addUser('twitter', twitUser));;
})
.redirectPath('/');
app.root = __dirname;
global.host = 'local.host';
require('./app/config')(app, exp, everyauth);
require('./app/server/router')(app,everyauth);
app.listen(3000, function(){
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
});
config.js
module.exports = function(app, exp, everyauth) {
app.configure(function(){
app.set('views', app.root + '/app/server/views');
app.set('view engine', 'jade');
app.set('view options', { doctype : 'html', pretty : true });
app.use(exp.bodyParser());
app.use(exp.cookieParser());
app.use(exp.session({ secret: 'super-duper-secret-secret' }));
app.use(everyauth.middleware(app));
app.use(exp.methodOverride());
app.use(require('stylus').middleware({ src: app.root + '/app/public' }));
app.use(exp.static(app.root + '/app/server'));
app.use(exp.static(app.root + '/app/public'));
});
router.js
var CT = require('./modules/country-list');
var AM = require('./modules/account-manager');
var EM = require('./modules/email-dispatcher');
var mongodb = require('mongodb');
module.exports = function(app, everyauth) {
// main login page //
app.get('/', function(req, res){
console.log('Root page called');
// This is the problem area. everyauth.loggedIn always comes out undefined
if(everyauth.loggedIn) {
console.log('The user has logged in');
}
// check if the user's credentials are saved in a cookie //
if (req.cookies.user == undefined || req.cookies.pass == undefined){
res.render('login', { locals: { title: 'Hello - Please Login To Your Account'}});
} else{
// attempt automatic login //
AM.autoLogin(req.cookies.user, req.cookies.pass, function(o){
if (o != null){
req.session.user = o;
res.redirect('/dashboard');
} else{
res.render('login', { locals: { title: 'Hello - Please Login To Your Account' }});
}
});
}
});
app.post('/', function(req, res){
console.log('app called');
AM.manualLogin(req.param('user'), req.param('pass'), function(e, o){
if (!o){
res.send(e, 400);
} else{
req.session.user = o;
if (req.param('remember-me') == 'true'){
res.cookie('user', o.user, { maxAge: 900000 });
res.cookie('pass', o.pass, { maxAge: 900000 });
}
res.send(o, 200);
}
});
});
app.post('/feedback', function(req,res) {
var server = new mongodb.Server('localhost',27017, {auto_reconnect: true}, {safe:true});
var db = new mongodb.Db('clicker', server);
db.open(function(err, db) {
if(!err) {
db.collection('feedback', function(err, collection) {
var currentTime = new Date().getTime();
var feedback = {value:req.param('feedback'), datetime:currentTime};
collection.insert(feedback);
db.close();
});
}
});
res.send('ok', 200);
});
// logged-in user homepage //
app.get('/home', function(req, res) {
if (req.session.user == null){
// if user is not logged-in redirect back to login page //
res.redirect('/');
} else{
res.render('home', {
locals: {
title : 'Control Panel',
countries : CT,
udata : req.session.user
}
});
}
});
app.get('/dashboard', function(req, res) {
if (req.session.user == null){
// if user is not logged-in redirect back to login page //
res.redirect('/');
} else{
res.render('dashboard', {
locals: {
title : 'Dashboard',
countries : CT,
udata : req.session.user
}
});
}
});
app.post('/home', function(req, res){
if (req.param('user') != undefined) {
AM.update({
user : req.param('user'),
name : req.param('name'),
email : req.param('email'),
country : req.param('country'),
pass : req.param('pass')
}, function(o){
if (o){
req.session.user = o;
// udpate the user's login cookies if they exists //
if (req.cookies.user != undefined && req.cookies.pass != undefined){
res.cookie('user', o.user, { maxAge: 900000 });
res.cookie('pass', o.pass, { maxAge: 900000 });
}
res.send('ok', 200);
} else{
res.send('error-updating-account', 400);
}
});
} else if (req.param('logout') == 'true'){
res.clearCookie('user');
res.clearCookie('pass');
req.session.destroy(function(e){ res.send('ok', 200); });
}
});
// creating new accounts //
app.get('/signup', function(req, res) {
res.render('signup', { locals: { title: 'Signup', countries : CT } });
});
app.post('/signup', function(req, res){
AM.signup({
name : req.param('name'),
email : req.param('email'),
user : req.param('user'),
pass : req.param('pass'),
country : req.param('country')
}, function(e, o){
if (e){
res.send(e, 400);
} else{
res.send('ok', 200);
}
});
});
// password reset //
app.post('/lost-password', function(req, res){
// look up the user's account via their email //
AM.getEmail(req.param('email'), function(o){
if (o){
res.send('ok', 200);
EM.dispatchResetPasswordLink(o, function(e, m){
// this callback takes a moment to return //
// should add an ajax loader to give user feedback //
if (!e) {
// res.send('ok', 200);
} else{
res.send('email-server-error', 400);
for (k in e) console.log('error : ', k, e[k]);
}
});
} else{
res.send('email-not-found', 400);
}
});
});
app.get('/reset-password', function(req, res) {
var email = req.query["e"];
var passH = req.query["p"];
AM.validateLink(email, passH, function(e){
if (e != 'ok'){
res.redirect('/');
} else{
// save the user's email in a session instead of sending to the client //
req.session.reset = { email:email, passHash:passH };
res.render('reset', { title : 'Reset Password' });
}
})
});
app.post('/reset-password', function(req, res) {
var nPass = req.param('pass');
// retrieve the user's email from the session to lookup their account and reset password //
var email = req.session.reset.email;
// destory the session immediately after retrieving the stored email //
req.session.destroy();
AM.setPassword(email, nPass, function(o){
if (o){
res.send('ok', 200);
} else{
res.send('unable to update password', 400);
}
})
});
// view & delete accounts //
app.get('/print', function(req, res) {
AM.getAllRecords( function(e, accounts){
res.render('print', { locals: { title : 'Account List', accts : accounts } });
})
});
app.post('/delete', function(req, res){
AM.delete(req.body.id, function(e, obj){
if (!e){
res.clearCookie('user');
res.clearCookie('pass');
req.session.destroy(function(e){ res.send('ok', 200); });
} else{
res.send('record not found', 400);
}
});
});
app.get('/reset', function(req, res) {
AM.delAllRecords( );
res.redirect('/print');
});
app.get('*', function(req, res) { res.render('404', { title: 'Page Not Found'}); });
};
}
To enable the express helpers like everyauth.loggedIn you have to call:
everyauth.helpExpress(app);
I am not sure why your code doesn't work. I had an example which works correctly but it needs mongodb. Just pushed to github if you want to have a try.
link to github

Resources