From 5dfbf9ec4727a4cfb41b60d8b94359abda847e72 Mon Sep 17 00:00:00 2001 From: emad-salah Date: Sat, 18 Apr 2020 20:19:22 +0100 Subject: [PATCH 1/2] Last seen middleware --- src/routes.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/routes.js b/src/routes.js index 3bc5b288..b1905a26 100644 --- a/src/routes.js +++ b/src/routes.js @@ -147,6 +147,14 @@ module.exports = async ( return true; }; + const lastSeenMiddleware = (req, res, next) => { + const {authorization} = req.headers + const {path} = req + if (!nonEncryptedRoutes.includes(path) && authorization) { + GunActions.setLastSeenApp() + } + } + const unlockWallet = password => new Promise((resolve, reject) => { try { @@ -303,6 +311,8 @@ module.exports = async ( } }); + app.use(lastSeenMiddleware); + app.use(["/ping"], responseTime()); /** From db90b8b8e3b58750fc98ba907ca930d70499e819 Mon Sep 17 00:00:00 2001 From: emad-salah Date: Sat, 18 Apr 2020 20:29:45 +0100 Subject: [PATCH 2/2] Bug fix --- src/routes.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes.js b/src/routes.js index b1905a26..5d2bfc56 100644 --- a/src/routes.js +++ b/src/routes.js @@ -148,9 +148,9 @@ module.exports = async ( }; const lastSeenMiddleware = (req, res, next) => { - const {authorization} = req.headers - const {path} = req - if (!nonEncryptedRoutes.includes(path) && authorization) { + const { authorization } = req.headers + const { path, method } = req + if (!unprotectedRoutes[method][path] && authorization && GunDB.isAuthenticated()) { GunActions.setLastSeenApp() } }