Skip to content

Commit

Permalink
Mfancher/no revoke active session fix (#983)
Browse files Browse the repository at this point in the history
* Wire Password Reset

* Remove unecessary reset temp password code that isn't used with temp password.

We use the link and token method for resetting temp passwords, no need to have temporary password code any longer

* Flag session from the requested token with current
  • Loading branch information
FancMa01 authored Jan 3, 2025
1 parent 7af9db4 commit fbef9bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const MyAccountTable = ({ user }) => {
if (!sessions?.success) {
return;
}

setSessions(sessions.data);
return;
};
Expand All @@ -36,7 +37,10 @@ const MyAccountTable = ({ user }) => {
title: 'Revoke',
dataIndex: 'id',
key: 'id',
render: (id) => {
render: (id, current) => {
if (current.current) {
return <span>Active Session</span>;
}
return (
<a
onClick={async () => {
Expand Down
11 changes: 11 additions & 0 deletions Tombolo/server/controllers/sessionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand Down

0 comments on commit fbef9bc

Please sign in to comment.