From b368e1dfa069487dd34ff7bea526eb4ff467d00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9line=20S=C3=A8be?= <87119259+CelineSebe@users.noreply.github.com> Date: Wed, 7 Aug 2024 17:46:52 +0200 Subject: [PATCH] [backend/frontend] Fix Kill all session button in the user overview (#7837) Co-authored-by: Souad Hadjiat --- .../src/private/components/settings/users/User.tsx | 5 ++++- opencti-platform/opencti-graphql/src/database/session.js | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/opencti-platform/opencti-front/src/private/components/settings/users/User.tsx b/opencti-platform/opencti-front/src/private/components/settings/users/User.tsx index ca7dd9f5b077..efb5d3ed9385 100644 --- a/opencti-platform/opencti-front/src/private/components/settings/users/User.tsx +++ b/opencti-platform/opencti-front/src/private/components/settings/users/User.tsx @@ -212,9 +212,10 @@ type Session = { interface UserProps { data: User_user$key; + refetch: () => void; } -const User: FunctionComponent = ({ data }) => { +const User: FunctionComponent = ({ data, refetch }) => { const classes = useStyles(); const { t_i18n, nsdt, fsd, fldt } = useFormatter(); const { me } = useAuth(); @@ -258,6 +259,7 @@ const User: FunctionComponent = ({ data }) => { onCompleted: () => { setKilling(false); handleCloseKillSession(); + refetch(); }, }); } @@ -281,6 +283,7 @@ const User: FunctionComponent = ({ data }) => { onCompleted: () => { setKilling(false); handleCloseKillSessions(); + refetch(); }, }); }; diff --git a/opencti-platform/opencti-graphql/src/database/session.js b/opencti-platform/opencti-graphql/src/database/session.js index 9c3c2effc71d..39e38b50dc3c 100644 --- a/opencti-platform/opencti-graphql/src/database/session.js +++ b/opencti-platform/opencti-graphql/src/database/session.js @@ -98,12 +98,14 @@ export const killSession = async (id) => { }; export const killUserSessions = async (userId) => { + const { store } = applicationSession; const sessions = await findUserSessions(userId); const sessionsIds = sessions.map((s) => s.id); const killedSessions = []; for (let index = 0; index < sessionsIds.length; index += 1) { const sessionId = sessionsIds[index]; - const killedSession = await killSession(sessionId); + const sessId = sessionId.split(store.prefix)[1]; + const killedSession = await killSession(sessId); killedSessions.push(killedSession); } return killedSessions;