Skip to content

Commit

Permalink
Use mongo for express session storage
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanfwalker committed Jul 6, 2017
1 parent af1a9c9 commit 051da79
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .env.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MONGODBURI=localhost:27017
MONGODBURI=mongodb://localhost:27017
NEXMO_API_KEY=<add key here>
NEXMO_API_SECRET=<add secret here>
NODE_ENV=production
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ script:
- npm run build
install:
- npm i -g npm@latest
- cp .env.dist .env
- npm install
- cd client
- npm install
Expand All @@ -15,7 +16,7 @@ install:
services:
- mongodb
env:
- MONGODBURI=localhost:27017/smsup
- MONGODBURI=mongodb://localhost:27017/smsup
SUPPORTED_LOCALES=en,fa,so
ACTIVE_GATEWAY=nexmo
MEXCOM_PREMIUM_KEYWORDS=APPS10
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
"babel-preset-react": "^6.16.0",
"bluebird": "^3.4.7",
"body-parser": "~1.15.2",
"connect-mongodb-session": "^1.3.0",
"cookie-parser": "~1.4.3",
"debug": "~2.2.0",
"eslint-plugin-flowtype": "^2.34.1",
"express": "~4.14.0",
"express-ipfilter": "^0.2.1",
"express-session": "^1.15.2",
Expand Down
5 changes: 5 additions & 0 deletions server/admin/admin-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const passwordless = require('passwordless');
const MongoStore = require('passwordless-mongostore-bcrypt-node');
const logger = require('winston');
const session = require('express-session');
const MongoSessionStore = require('connect-mongodb-session')(session);

const loginForm = `<html>
<body>
Expand Down Expand Up @@ -35,6 +36,10 @@ function setupAuth(app) {
secret: process.env.ADMIN_AUTH_SECRET,
resave: false,
saveUninitialized: true,
store: new MongoSessionStore({
uri: process.env.MONGODBURI,
collection: 'sessions',
}),
}));

app.post(
Expand Down

0 comments on commit 051da79

Please sign in to comment.