Skip to content

Commit

Permalink
fix #306. session 存在 mongo 中
Browse files Browse the repository at this point in the history
  • Loading branch information
alsotang committed Apr 14, 2014
1 parent c659146 commit 62a8fde
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app.js
Expand Up @@ -19,6 +19,7 @@ var GitHubStrategy = require('passport-github').Strategy;
var githubStrategyMiddleware = require('./middlewares/github_strategy');
var routes = require('./routes');
var auth = require('./middlewares/auth');
var MongoStore = require('connect-mongo')(express);

var maxAge = 3600000 * 24 * 30;
var staticDir = path.join(__dirname, 'public');
Expand Down Expand Up @@ -58,7 +59,10 @@ app.use(express.bodyParser({
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.session({
secret: config.session_secret
secret: config.session_secret,
store: new MongoStore({
db: config.db_name,
}),
}));
app.use(passport.initialize());
// custom middleware
Expand Down
1 change: 1 addition & 0 deletions config.default.js
Expand Up @@ -32,6 +32,7 @@ var config = {
upload_dir: path.join(__dirname, 'public', 'user_data', 'images'),

db: 'mongodb://127.0.0.1/node_club_dev',
db_name: 'node_club_dev',
session_secret: 'node_club',
auth_cookie_name: 'node_club',
port: 3000,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -23,7 +23,8 @@
"passport": "~0.1.17",
"passport-github": "~0.1.5",
"forever": "~0.10.11",
"marked": "~0.3.2"
"marked": "~0.3.2",
"connect-mongo": "^0.4.0"
},
"devDependencies": {
"supertest": "*",
Expand Down

0 comments on commit 62a8fde

Please sign in to comment.