forked from fnakstad/angular-client-side-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (39 loc) · 1.75 KB
/
server.js
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
38
39
40
41
42
43
44
45
46
47
var express = require('express')
, http = require('http')
, passport = require('passport')
, path = require('path')
, User = require('./server/models/User.js');
var app = module.exports = express();
app.set('views', __dirname + '/client/views');
app.set('view engine', 'jade');
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.static(path.join(__dirname, 'client')));
app.use(express.cookieParser());
app.use(express.cookieSession(
{
secret: process.env.COOKIE_SECRET || "Superdupersecret"
}));
app.configure('development', 'production', function() {
app.use(express.csrf());
app.use(function(req, res, next) {
res.cookie('XSRF-TOKEN', req.csrfToken());
next();
});
});
app.use(passport.initialize());
app.use(passport.session());
passport.use(User.localStrategy);
passport.use(User.twitterStrategy()); // Comment out this line if you don't want to enable login via Twitter
passport.use(User.facebookStrategy()); // Comment out this line if you don't want to enable login via Facebook
passport.use(User.googleStrategy()); // Comment out this line if you don't want to enable login via Google
passport.use(User.linkedInStrategy()); // Comment out this line if you don't want to enable login via LinkedIn
passport.use(User.googlePlusStrategy()); // Comment out this line if you don't want to enable login via Google Plus
passport.serializeUser(User.serializeUser);
passport.deserializeUser(User.deserializeUser);
require('./server/routes.js')(app);
app.set('port', process.env.PORT || 8000);
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});