03-sessions.js
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// # sessions
var session = require('express-session');
var cookieParser = require('cookie-parser');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
exports = module.exports = function (settings, sessions) {
var app = this;
// pass a secret to cookieParser() for signed cookies
app.all(settings.notApiRouteRegexp, cookieParser(settings.cookieParser));
// add req.session cookie support
settings.session.store = sessions;
app.all(settings.notApiRouteRegexp, session(settings.session));
// add flash message support
app.use(session(settings.session));
app.use(passport.initialize());
app.use(passport.session());
//// add passport strategies
passport.use(new LocalStrategy(settings.localStrategy,function(req, username, password, done){
console.log("@@@@@",username,password)
done(null,{user:'aaaaaa'});
}));
passport.serializeUser(function(user, done){
done(null, {});
});
passport.deserializeUser(function(user, done){
done(null, {});
});
};
exports['@require'] = ['igloo/settings', 'igloo/sessions'];