From d865df090cda1f473a70b3bdbd6b442572946d67 Mon Sep 17 00:00:00 2001 From: Elyor Djalilov Date: Wed, 12 Jun 2024 18:28:42 +0500 Subject: [PATCH] fixed logout from all sessions --- .../UserSessionsPanel/AllSessionsBlock.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/client/src/components/panels/UserSessionsPanel/AllSessionsBlock.js b/packages/client/src/components/panels/UserSessionsPanel/AllSessionsBlock.js index e154970f72..7fc9672026 100644 --- a/packages/client/src/components/panels/UserSessionsPanel/AllSessionsBlock.js +++ b/packages/client/src/components/panels/UserSessionsPanel/AllSessionsBlock.js @@ -26,20 +26,26 @@ const AllSessionsBlock = (props) => { t, connections, setConnections, + userLastSession, fetchData, - removeAllActiveSessionsById, + removeAllExceptThisEventId, } = props; const [isLoading, setIsLoading] = useState(false); const isDisabled = connections.length > 0; const onLogoutClick = async () => { + const exceptId = userLastSession.connections[0]?.id; try { setIsLoading(true); - await removeAllActiveSessionsById(connections[0]?.userId); - fetchData(); - setConnections([]); - toastr.success("Successfully logout all sessions"); + await removeAllExceptThisEventId(connections[0]?.id); + + const filteredConnections = connections.filter( + (connection) => connection.id === exceptId, + ); + setConnections(filteredConnections); + await fetchData(); + toastr.success("Successfully logout except this"); } catch (error) { toastr.error(error); } finally { @@ -68,13 +74,15 @@ const AllSessionsBlock = (props) => { }; export default inject(({ setup, peopleStore }) => { - const { removeAllActiveSessionsById } = setup; - const { connections, setConnections, fetchData } = peopleStore.selectionStore; + const { removeAllExceptThisEventId } = setup; + const { connections, setConnections, fetchData, userLastSession } = + peopleStore.selectionStore; return { connections, setConnections, + userLastSession, fetchData, - removeAllActiveSessionsById, + removeAllExceptThisEventId, }; })(observer(AllSessionsBlock));