moved connect-redis to the redis.db file, expose the sessionStore from redis.js db file, do the same for mongo db with mongo-connect

v1.18.x
Baris Soner Usakli 11 years ago
parent 95db5f93cb
commit 6d79521922

@ -6,6 +6,9 @@
redis = require('redis'),
winston = require('winston'),
nconf = require('nconf'),
express = require('express'),
connectRedis = require('connect-redis')(express),
redis_socket_or_host = nconf.get('redis:host'),
utils = require('./../../public/src/utils.js');
@ -17,6 +20,11 @@
redisClient = redis.createClient(nconf.get('redis:port'), nconf.get('redis:host'));
}
module.sessionStore = new connectRedis({
client: redisClient,
ttl: 60 * 60 * 24 * 30
});
module.client = redisClient;
module.type = 'redis';

@ -43,7 +43,6 @@ var user = require('./user'),
}
if (res) {
console.log('logged in', uid);
next(null, {
user: {
uid: uid

@ -15,7 +15,6 @@
passport.use(new passportLocal(function(user, password, next) {
login_module.loginViaLocal(user, password, function(err, login) {
if (!err) {
console.log('LOGGED IN');
next(null, login.user);
} else {
next(null, false, err);

@ -5,7 +5,6 @@ var path = require('path'),
express_namespace = require('express-namespace'),
WebServer = express(),
server = require('http').createServer(WebServer),
RedisStore = require('connect-redis')(express),
nconf = require('nconf'),
winston = require('winston'),
validator = require('validator'),
@ -142,19 +141,8 @@ var path = require('path'),
app.use(express.cookieParser()); // If you want to parse cookies (res.cookies)
// TODO : this uses redis
/*app.use(express.session({
store: new RedisStore({
client: RDB,
ttl: 60 * 60 * 24 * 30
}),
secret: nconf.get('secret'),
key: 'express.sid',
cookie: {
maxAge: 60 * 60 * 24 * 30 * 1000 // 30 days
}
}));*/
app.use(express.cookieSession({
app.use(express.session({
store: db.sessionStore,
secret: nconf.get('secret'),
key: 'express.sid',
cookie: {

@ -12,14 +12,6 @@ var cookie = require('cookie'),
RedisStoreLib = require('connect-redis')(express),
db = require('./database'),
redis = require('redis'),
redisClient = redis.createClient(nconf.get('redis:port'), nconf.get('redis:host')),
RedisStore = new RedisStoreLib({
client: redisClient,
ttl: 60 * 60 * 24 * 14
}),
user = require('./user'),
Groups = require('./groups'),
posts = require('./posts'),
@ -74,7 +66,7 @@ websockets.init = function(io) {
// Validate the session, if present
socketCookieParser(hs, {}, function(err) {
sessionID = socket.handshake.signedCookies["express.sid"];
RedisStore.get(sessionID, function(err, sessionData) {
db.sessionStore.get(sessionID, function(err, sessionData) {
if (!err && sessionData && sessionData.passport && sessionData.passport.user) {
uid = users[sessionID] = sessionData.passport.user;
} else {

Loading…
Cancel
Save