Session store knex (#5432)

* Rotate JPG image on upload #4206

* fixes #3949 width/height generated for gif and tif

* API hooks for event added for auth.login #4079

* updated doc for api hooks for new auth.login event

* Style tweaks

* Update docs

* Tweak docs some more

* Spelling error

* Allow non-required flags and pass to hook

* SDK - Persistent login refresh fixes #4113

* Fixed #4145 SDK, Token Expired error

* Spell check

* Docs Spell check

* Docs Spell check

* Docs Spell check

* update docs for sdk-js

* To delete all expired session from db on login

* corrected the condition for the delete

* changed the from Date.now to new date .

* Move it inline

* Added Knex option for Session store

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
Pyll Gomez
2021-05-03 11:46:42 -04:00
committed by GitHub
parent 7817f8f9bb
commit 09b19b9191
3 changed files with 18 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
import expressSession, { Store } from 'express-session';
import env from '../env';
import { getConfigFromEnv } from '../utils/get-config-from-env';
import database from '../database';
let store: Store | undefined = undefined;
if (env.SESSION_STORE === 'redis') {
@@ -17,4 +17,12 @@ if (env.SESSION_STORE === 'memcache') {
store = new MemcachedStore(getConfigFromEnv('SESSION_MEMCACHE_'));
}
if (env.SESSION_STORE === 'database') {
const KnexSessionStore = require('connect-session-knex')(expressSession);
store = new KnexSessionStore({
knex: database,
tablename: 'oauth_sessions', // optional. Defaults to 'sessions'
});
}
export const session = expressSession({ store, secret: env.SECRET as string, saveUninitialized: false, resave: false });