-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(server): fix setting TTL index on collection : sessions error
- Loading branch information
Showing
5 changed files
with
25 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,8 @@ var path = require('path'); | |
var config = require('./environment');<% if (filters.auth) { %> | ||
var passport = require('passport');<% } %><% if (filters.twitterAuth) { %> | ||
var session = require('express-session'); | ||
var mongoStore = require('connect-mongo')(session);<% } %> | ||
var mongoStore = require('connect-mongo')(session); | ||
var mongoose = require('mongoose');<% } %> | ||
|
||
module.exports = function(app) { | ||
var env = app.get('env'); | ||
|
@@ -32,19 +33,16 @@ module.exports = function(app) { | |
app.use(cookieParser()); | ||
<% if (filters.auth) { %>app.use(passport.initialize());<% } %><% if (filters.twitterAuth) { %> | ||
|
||
// Persist sessions with mongoStore | ||
// We need to enable sessions for passport twitter because its an oauth 1.0 strategy | ||
app.use(session({ | ||
secret: config.secrets.session, | ||
resave: true, | ||
saveUninitialized: true, | ||
store: new mongoStore({ | ||
url: config.mongo.uri, | ||
collection: 'sessions' | ||
}, function () { | ||
console.log('db connection open' ); | ||
}) | ||
}));<% } %> | ||
mongoose.connection.on('connected', function () { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
DaftMonk
Author
Member
|
||
// Persist sessions with mongoStore | ||
// We need to enable sessions for passport twitter because its an oauth 1.0 strategy | ||
app.use(session({ | ||
secret: config.secrets.session, | ||
resave: true, | ||
saveUninitialized: true, | ||
store: new mongoStore({ mongoose_connection: mongoose.connection }) | ||
})); | ||
});<% } %> | ||
|
||
if ('production' === env) { | ||
app.use(favicon(path.join(config.root, 'public', 'favicon.ico'))); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
running this code in mongoose callback breaks Twitter authentication with: