소스 검색

Cookie policy update

isundil 1 년 전
부모
커밋
923abf8cb1
3개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      package.json
  2. 6 0
      src/databaseHelper.js
  3. 1 1
      src/routerUtils.js

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "craftlabhttpserver",
-  "version": "20240325.1",
+  "version": "20240804.1",
   "description": "",
   "main": "main.js",
   "scripts": {

+ 6 - 0
src/databaseHelper.js

@@ -163,6 +163,12 @@ DatabaseHelper.prototype.fetch = async function(objectPrototype, where, orderBy)
     return resultArr;
 }
 
+DatabaseHelper.prototype.remove = async function(objectPrototype, where) {
+    let whereArgs = this.buildWhere(where);
+    let query = "delete from `" +objectPrototype.prototype.getTableName.call(null) +"` where " +whereArgs.columns.join(" and ");
+    return await this.runSql(query, whereArgs.args, false);
+}
+
 DatabaseHelper.prototype.fetchRaw = async function(columns, tableName, where, orderBy) {
     let whereArgs = this.buildWhere(where);
     let query = "select " + (Array.isArray(columns) ? columns.join(","): columns) +" from `" +tableName +"` where " +whereArgs.columns.join(" and ");

+ 1 - 1
src/routerUtils.js

@@ -69,7 +69,7 @@ RouterUtils.prototype.onRequest = function(req, res) {
     req.sessionObj = Security.getSessionObj(req.cookies);
     if (!req.sessionObj) {
         const log = Security.createSession(req);
-        res.setHeader("Set-Cookie", `${Security.SESSION_COOKIE}=${log.key};Path=/`);
+        res.setHeader("Set-Cookie", `${Security.SESSION_COOKIE}=${log.key};Path=/;SameSite=Lax`);
         req.sessionObj = log.data;
     }
 }