Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Bare Minimum Passport Login Pages App.js

/*....*/
var logger = require('morgan');

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');

var app = express();

const passport = require('passport');
var flash    = require('connect-flash');
var session      = require('express-session');

/*mongodb*/

// Set up mongoose connection
var mongoose = require('mongoose');
/*mongodb stuff*/ 
 
//////
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use(session({ secret: 'unknown' })); // session secret

// Passport middleware

app.use(passport.initialize());
app.use(passport.session()); // persistent login sessions
app.use(flash()); // use connect-flash for flash messages stored in session
 
app.use('/', indexRouter);
app.use('/users', usersRouter);

 
PREVIOUS NEXT
Tagged: #Bare #Minimum #Passport #Login #Pages
ADD COMMENT
Topic
Name
4+3 =