File tree Expand file tree Collapse file tree 2 files changed +28
-5
lines changed
Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change 44
55### Changed
66- Update to ` connect-mongo@5 ` .
7+ - Make the ` session-mongodb.ttl ` config value default to a value computed
8+ from ` express.session.ttl ` . This does not change the default of 30
9+ minutes but it does allow the express session TTL to properly propagate
10+ to the ` MongoStore ` session store instance w/o the need for setting
11+ the ` session-mongodb.ttl ` configuration value independently. It can
12+ still be set independently, overiding the computed value if desired.
713
814## 6.0.0 - 2022-04-29
915
Original file line number Diff line number Diff line change 11/*!
2- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
2+ * Copyright (c) 2012-2025 Digital Bazaar, Inc. All rights reserved.
33 */
4- import { config } from '@bedrock/core' ;
4+ import { config , util } from '@bedrock/core' ;
5+ import '@bedrock/express' ;
6+
7+ const cc = util . config . main . computer ( ) ;
58
69config [ 'session-mongodb' ] = {
7- collection : 'session' ,
8- // timeout is in seconds (time for session to live on the server)
9- ttl : 60 * 30
10+ collection : 'session'
1011} ;
12+
13+ // create computed `ttl` property based on express config...
14+
15+ // default to 30 minute TTL expressed in seconds
16+ const THIRTY_MINUTES = 60 * 30 ;
17+
18+ // timeout is in seconds (time for session to live on the server)
19+ cc ( 'session-mongodb.ttl' , ( ) => {
20+ if ( config . express ?. session ) {
21+ // express session ttl is in milliseconds, convert to seconds
22+ const { ttl = THIRTY_MINUTES * 1000 } = config . express . session ;
23+ // round down to ensure session doesn't live beyond configured value
24+ return Math . floor ( ttl / 1000 ) ;
25+ }
26+ return THIRTY_MINUTES ;
27+ } ) ;
You can’t perform that action at this time.
0 commit comments