Add TTL to Redis session and expose session in ctx.state

This commit is contained in:
Aurélien Georget 2017-03-06 11:47:33 +01:00
parent 957cc17d0a
commit a5a1d98961

View File

@ -24,7 +24,7 @@ module.exports = strapi => {
defaults: {
key: 'strapi.sid',
prefix: 'strapi:sess:',
ttl: null,
ttl: 24 * 60 * 60 * 1000, // One day in ms
rolling: false,
secretKeys: ['mySecretKey1', 'mySecretKey2'],
cookie: {
@ -59,6 +59,12 @@ module.exports = strapi => {
);
strapi.app.use(strapi.middlewares.convert(strapi.middlewares.genericSession(options)));
strapi.app.use((ctx, next) => {
ctx.state = ctx.state || {};
ctx.state.session = ctx.session || {};
return next();
});
} catch (err) {
return cb(err);
}