parse-dashboard 8.0.0 → 8.1.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,9 +55,10 @@ function initialize(app, options) {
55
55
 
56
56
  const cookieSessionSecret = options.cookieSessionSecret || require('crypto').randomBytes(64).toString('hex');
57
57
  const cookieSessionMaxAge = options.cookieSessionMaxAge;
58
+ const cookieSessionStore = options.cookieSessionStore;
58
59
 
59
60
  app.use(require('body-parser').urlencoded({ extended: true }));
60
- app.use(require('express-session')({
61
+ const sessionConfig = {
61
62
  name: 'parse_dash',
62
63
  secret: cookieSessionSecret,
63
64
  resave: false,
@@ -67,7 +68,14 @@ function initialize(app, options) {
67
68
  httpOnly: true,
68
69
  sameSite: 'lax',
69
70
  }
70
- }));
71
+ };
72
+
73
+ // Add custom session store if provided
74
+ if (cookieSessionStore) {
75
+ sessionConfig.store = cookieSessionStore;
76
+ }
77
+
78
+ app.use(require('express-session')(sessionConfig));
71
79
  app.use(require('connect-flash')());
72
80
  app.use(passport.initialize());
73
81
  app.use(passport.session());
@@ -82,7 +82,11 @@ module.exports = function(config, options) {
82
82
  const users = config.users;
83
83
  const useEncryptedPasswords = config.useEncryptedPasswords ? true : false;
84
84
  const authInstance = new Authentication(users, useEncryptedPasswords, mountPath);
85
- authInstance.initialize(app, { cookieSessionSecret: options.cookieSessionSecret, cookieSessionMaxAge: options.cookieSessionMaxAge });
85
+ authInstance.initialize(app, {
86
+ cookieSessionSecret: options.cookieSessionSecret,
87
+ cookieSessionMaxAge: options.cookieSessionMaxAge,
88
+ cookieSessionStore: options.cookieSessionStore
89
+ });
86
90
 
87
91
  // CSRF error handler
88
92
  app.use(function (err, req, res, next) {