From 70e4b9e214055e4af113c9fb1e42fc9dd7061b6b Mon Sep 17 00:00:00 2001 From: Avris Date: Tue, 23 Nov 2021 14:44:24 +0100 Subject: [PATCH] #274 save last login date --- migrations/040-last-active.sql | 6 ++++++ server/routes/user.js | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 migrations/040-last-active.sql diff --git a/migrations/040-last-active.sql b/migrations/040-last-active.sql new file mode 100644 index 00000000..9ccc0f11 --- /dev/null +++ b/migrations/040-last-active.sql @@ -0,0 +1,6 @@ +-- Up + +ALTER TABLE users ADD COLUMN lastActive INTEGER NULL; + +-- Down + diff --git a/server/routes/user.js b/server/routes/user.js index f592c427..9b867085 100644 --- a/server/routes/user.js +++ b/server/routes/user.js @@ -176,6 +176,9 @@ const reloadUser = async (req, res, next) => { return; } + console.log('reloadUser'); + await req.db.get(SQL`UPDATE users SET lastActive = ${+new Date} WHERE id = ${req.user.id}`); + if (req.user.username !== dbUser.username || req.user.email !== dbUser.email || req.user.roles !== dbUser.roles