fixed logout from all sessions
This commit is contained in:
parent
efa0efbe91
commit
d865df090c
@ -26,20 +26,26 @@ const AllSessionsBlock = (props) => {
|
|||||||
t,
|
t,
|
||||||
connections,
|
connections,
|
||||||
setConnections,
|
setConnections,
|
||||||
|
userLastSession,
|
||||||
fetchData,
|
fetchData,
|
||||||
removeAllActiveSessionsById,
|
removeAllExceptThisEventId,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const isDisabled = connections.length > 0;
|
const isDisabled = connections.length > 0;
|
||||||
|
|
||||||
const onLogoutClick = async () => {
|
const onLogoutClick = async () => {
|
||||||
|
const exceptId = userLastSession.connections[0]?.id;
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
await removeAllActiveSessionsById(connections[0]?.userId);
|
await removeAllExceptThisEventId(connections[0]?.id);
|
||||||
fetchData();
|
|
||||||
setConnections([]);
|
const filteredConnections = connections.filter(
|
||||||
toastr.success("Successfully logout all sessions");
|
(connection) => connection.id === exceptId,
|
||||||
|
);
|
||||||
|
setConnections(filteredConnections);
|
||||||
|
await fetchData();
|
||||||
|
toastr.success("Successfully logout except this");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toastr.error(error);
|
toastr.error(error);
|
||||||
} finally {
|
} finally {
|
||||||
@ -68,13 +74,15 @@ const AllSessionsBlock = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default inject(({ setup, peopleStore }) => {
|
export default inject(({ setup, peopleStore }) => {
|
||||||
const { removeAllActiveSessionsById } = setup;
|
const { removeAllExceptThisEventId } = setup;
|
||||||
const { connections, setConnections, fetchData } = peopleStore.selectionStore;
|
const { connections, setConnections, fetchData, userLastSession } =
|
||||||
|
peopleStore.selectionStore;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
connections,
|
connections,
|
||||||
setConnections,
|
setConnections,
|
||||||
|
userLastSession,
|
||||||
fetchData,
|
fetchData,
|
||||||
removeAllActiveSessionsById,
|
removeAllExceptThisEventId,
|
||||||
};
|
};
|
||||||
})(observer(AllSessionsBlock));
|
})(observer(AllSessionsBlock));
|
||||||
|
Loading…
Reference in New Issue
Block a user