diff options
author | Marvin Borner | 2020-10-02 19:56:02 +0200 |
---|---|---|
committer | Marvin Borner | 2020-10-02 19:56:02 +0200 |
commit | 762794cecdb0b12b58db0de16d31c8d7c216171c (patch) | |
tree | 4b442ae2e8ae9df80dac26cd31a574da4a5d896d | |
parent | 3ffa108bebadd448ba09a8931addba69fddfc72c (diff) |
Switched to redis session store
-rw-r--r-- | app.js | 13 | ||||
-rw-r--r-- | package.json | 4 | ||||
-rw-r--r-- | tables.sql | 2 |
3 files changed, 16 insertions, 3 deletions
@@ -9,7 +9,18 @@ const quotes = require("./quotes"); const app = express(); // TODO: Use secure: true in production -app.use(session({ secret: "keyboard cat", resave: false, saveUninitialized: true, cookie: { secure: false } })); +const redis = require("redis"); +const RedisStore = require("connect-redis")(session); +const redisClient = redis.createClient(); +app.use( + session({ + store: new RedisStore({ client: redisClient }), + secret: "keyboard cat", + resave: false, + saveUninitialized: true, + cookie: { secure: false }, + }) +); app.use(express.urlencoded({ extended: true })); app.use(express.json()); diff --git a/package.json b/package.json index a9691f4..6c65977 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,13 @@ "license": "MIT", "dependencies": { "bcrypt": "^5.0.0", + "connect-redis": "^5.0.0", "dotenv": "^8.2.0", "express": "^4.17.1", "express-rate-limit": "^5.1.3", "express-session": "^1.17.1", "mariadb": "^2.4.2", - "nanoid": "^3.1.12" + "nanoid": "^3.1.12", + "redis": "^3.0.2" } } @@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS class( CREATE TABLE IF NOT EXISTS users( id INTEGER PRIMARY KEY AUTO_INCREMENT, - username VARCHAR(255) NOT NULL, + username VARCHAR(255) NOT NULL UNIQUE, name VARCHAR(255) NOT NULL, middlename VARCHAR(255) DEFAULT NULL, surname VARCHAR(255) NOT NULL, |