Browse Source

v1.0.6: Server options: session secret

CrazyDoctor 8 months ago
parent
commit
e1b274dcad

+ 2 - 1
dist/middlewares/SessionMiddleware.js

@@ -8,10 +8,11 @@ const express_session_1 = __importDefault(require("express-session"));
 const util_1 = require("../base/util");
 class SessionMiddleware extends http_1.Middleware {
     constructor() {
+        var _a;
         super(...arguments);
         this.order = -98;
         this.route = null;
-        this.action = (0, express_session_1.default)({ secret: util_1.Guid.new(), resave: false, saveUninitialized: false });
+        this.action = (0, express_session_1.default)({ secret: ((_a = this.context.options) === null || _a === void 0 ? void 0 : _a.sessionSecret) || util_1.Guid.new(), resave: false, saveUninitialized: false });
     }
 }
 exports.default = SessionMiddleware;

+ 1 - 1
dist/middlewares/SessionMiddleware.js.map

@@ -1 +1 @@
-{"version":3,"file":"SessionMiddleware.js","sourceRoot":"","sources":["../../lib/middlewares/SessionMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,uCAA0C;AAC1C,sEAAsC;AACtC,uCAAoC;AAEpC,MAAM,iBAAkB,SAAQ,iBAAU;IAA1C;;QACW,UAAK,GAAG,CAAC,EAAE,CAAC;QACZ,UAAK,GAAG,IAAI,CAAC;QACb,WAAM,GAAG,IAAA,yBAAO,EAAC,EAAE,MAAM,EAAE,WAAI,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7F,CAAC;CAAA;AAED,kBAAe,iBAAiB,CAAC"}
+{"version":3,"file":"SessionMiddleware.js","sourceRoot":"","sources":["../../lib/middlewares/SessionMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,uCAA0C;AAC1C,sEAAsC;AACtC,uCAAoC;AACpC,MAAM,iBAAkB,SAAQ,iBAAU;IAA1C;;;QACW,UAAK,GAAG,CAAC,EAAE,CAAC;QACZ,UAAK,GAAG,IAAI,CAAC;QACb,WAAM,GAAG,IAAA,yBAAO,EAAC,EAAE,MAAM,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,OAAO,0CAAE,aAAa,KAAI,WAAI,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC;IACpI,CAAC;CAAA;AAED,kBAAe,iBAAiB,CAAC"}

+ 1 - 2
lib/middlewares/SessionMiddleware.ts

@@ -1,11 +1,10 @@
 import { Middleware } from '../base/http';
 import session from 'express-session';
 import { Guid } from '../base/util';
-
 class SessionMiddleware extends Middleware {
 	protected order = -98;
 	protected route = null;
-	protected action = session({ secret: Guid.new(), resave: false, saveUninitialized: false });
+	protected action = session({ secret: this.context.options?.sessionSecret || Guid.new(), resave: false, saveUninitialized: false });
 }
 
 export default SessionMiddleware;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "org.crazydoctor.expressts",
-  "version": "1.0.5",
+  "version": "1.0.6",
   "devDependencies": {
     "@types/express-session": "^1.17.7",
     "@types/node": "^20.4.9",