mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
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:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user