0

I've been looking for authentication in nodeJs. I've looked at PassportJs and Everyauth. Both of them had old documentation and old version of express used. Things that depreciated in express 4+.

app.use(express.cookieParser());
app.use(express.bodyParser());

I had a look at this question, which had nice answers. But had no success implementing them on PassportJs or Everyauth. So does anyone know an method to implement this ? or can anyone give me an authentication tutorial for express 4+ nodeJs authentication ?

Community
  • 1
  • 1
Shamal Sandeep
  • 519
  • 4
  • 9

2 Answers2

2

Should work like this:

var bodyParser   = require('body-parser'),
    cookieParser = require('cookie-parser'),
    express      = require('express'),
    session      = require('express-session'),
    passport     = require('passport');

var app = express();

app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(session({
  secret: 'secrit cat',
  resave: true,
  saveUninitialized: true
}));
app.use(passport.initialize());
app.use(passport.session());
vesse
  • 4,871
  • 26
  • 35
0

Scotch.io has updated its tutorial series "Easy node authentication" :

These are the changes regarding passport :

Easy node authentication with ExpressJS 4.0

sebilasse
  • 4,278
  • 2
  • 37
  • 36