Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mfancher/15 minute retry fix #984

Merged
merged 8 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const ApplicationMenu = ({ applications, selected, handleApplicationChange }) =>
menu={{
items: getApplicationItems(applications),
onClick: (e) => {
console.log(e);
handleApplicationChange(e.key);
},
}}
Expand Down
20 changes: 10 additions & 10 deletions Tombolo/client-reactjs/src/components/layout/LeftNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const LeftNav = ({ collapsed, onCollapse, clusterLinkRef, appLinkRef }) => {

//control the disabled state of the menu items based on the application and cluster states
useEffect(() => {
if (applicationId && applicationId) {
if (application && applicationId) {
setDisabled(false);
} else {
setDisabled(true);
Expand Down Expand Up @@ -366,23 +366,23 @@ const LeftNav = ({ collapsed, onCollapse, clusterLinkRef, appLinkRef }) => {
),
getItem(
<>
{disabled || clusterDisabled ? (
{/* {disabled || clusterDisabled ? (
<>
<i className="fa fa-fw fa-users" />
<span style={{ marginLeft: '1rem' }}>Users</span>
</>
) : (
<Link style={{ color: 'rgba(255, 255, 255, 0.65)' }} to={'/admin/userManagement'}>
<i className="fa fa-fw fa-users" />
<span style={{ marginLeft: '1rem' }}>Users</span>
</Link>
)}
) : ( */}
<Link style={{ color: 'rgba(255, 255, 255, 0.65)' }} to={'/admin/userManagement'}>
<i className="fa fa-fw fa-users" />
<span style={{ marginLeft: '1rem' }}>Users</span>
</Link>
{/* )} */}
</>,
'11',
null,
null,
null,
clusterDisabled
null
// clusterDisabled
),
getItem(
<>
Expand Down
4 changes: 4 additions & 0 deletions Tombolo/client-reactjs/src/redux/actions/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ function getApplications() {
if (applicationsFinal.length === 0) {
dispatch({ type: Constants.NO_APPLICATION_FOUND, noApplication: true });
dispatch({ type: Constants.APPLICATIONS_RETRIEVED, payload: applicationsFinal });
dispatch({
type: Constants.APPLICATION_SELECTED,
application: { applicationId: null, applicationTitle: null },
});
return;
}
dispatch({ type: Constants.APPLICATIONS_RETRIEVED, payload: applicationsFinal });
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
4 changes: 4 additions & 0 deletions Tombolo/server/middlewares/tokenValidationMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ const tokenValidationMiddleware = async (req, res, next) => {

await generateAndSetCSRFToken(req, res, tokenDetails.newAccessToken);

//we need to update the req.user object with the new token details, so that when we pass it to the next middleware it has the correct details
//if we don't do this and a verifyUserRole middleware is used after this one, it will fail as the user details won't be there and end user will receive errors
req.user = await jwt.decode(tokenDetails.newAccessToken);

next();
}
} else {
Expand Down
Loading