diff --git a/Tombolo/client-reactjs/src/components/application/myAccount/myAccountTable.jsx b/Tombolo/client-reactjs/src/components/application/myAccount/myAccountTable.jsx index 29256172..5ecdb086 100644 --- a/Tombolo/client-reactjs/src/components/application/myAccount/myAccountTable.jsx +++ b/Tombolo/client-reactjs/src/components/application/myAccount/myAccountTable.jsx @@ -12,6 +12,7 @@ const MyAccountTable = ({ user }) => { if (!sessions?.success) { return; } + setSessions(sessions.data); return; }; @@ -36,7 +37,10 @@ const MyAccountTable = ({ user }) => { title: 'Revoke', dataIndex: 'id', key: 'id', - render: (id) => { + render: (id, current) => { + if (current.current) { + return Active Session; + } return ( { diff --git a/Tombolo/server/controllers/sessionController.js b/Tombolo/server/controllers/sessionController.js index 5d8de27a..0a6b9ed6 100644 --- a/Tombolo/server/controllers/sessionController.js +++ b/Tombolo/server/controllers/sessionController.js @@ -2,6 +2,7 @@ const jwt = require("jsonwebtoken"); const models = require("../models"); const { blacklistToken } = require("../utils/tokenBlackListing"); const logger = require("../config/logger"); +const { verifyToken } = require("../utils/authUtil"); const RefreshTokens = models.RefreshTokens; @@ -26,6 +27,16 @@ const activeSessionsByUserId = async (req, res) => { } }); + //grab current session token id from the request + const token = req.cookies.token; + let decoded = await verifyToken(token, process.env.JWT_SECRET); + const currentTokenId = decoded.tokenId; + + // Mark the current token + activeSessions.forEach((session) => { + session.dataValues.current = session.id === currentTokenId; + }); + // response res.status(200).json({ success: true, data: activeSessions }); } catch (err) {