fixed logoutall
This commit is contained in:
parent
0e9d0e9dc9
commit
8e43bb289a
@ -298,7 +298,6 @@
|
||||
"UseDigits": "Use digits",
|
||||
"UsedStorage": "Used: {{size}}",
|
||||
"UseHttp": "Use Http",
|
||||
"UserAlreadyLoggedOut": "The user {{displayName}} is already logged out",
|
||||
"UserAgreement": "I confirm and want to proceed",
|
||||
"UserLimitExceeded": "User limit exceeded. To proceed to the next step, please adjust the number of users or increase the {{productName}} user limit.",
|
||||
"UsersAreRegistered": "You selected users registered in your {{productName}}, with the roles already set. Please proceed to the next step or go back to select more users.",
|
||||
|
@ -295,7 +295,6 @@
|
||||
"UseDigits": "Использовать цифры",
|
||||
"UsedStorage": "Используемое: {{size}}",
|
||||
"UseHttp": "Использовать Http",
|
||||
"UserAlreadyLoggedOut": "Пользователь {{displayName}} уже вышел из системы.",
|
||||
"UserAgreement": "Я подтверждаю и хочу продолжить",
|
||||
"UserLimitExceeded": "Превышен лимит пользователя. Чтобы перейти к следующему шагу, измените количество пользователей или увеличьте лимит пользователей {{productName}}.",
|
||||
"UsersSectionDescription": "Раздел «Пользователи» включает пользователей, которых вы выбрали на предыдущем шаге. По умолчанию он всегда включен, и его нельзя отключить.",
|
||||
|
@ -25,46 +25,55 @@
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
import { useState } from "react";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { ModalDialog } from "@docspace/shared/components/modal-dialog";
|
||||
import { Checkbox } from "@docspace/shared/components/checkbox";
|
||||
import { Button } from "@docspace/shared/components/button";
|
||||
import { Text } from "@docspace/shared/components/text";
|
||||
import { toastr } from "@docspace/shared/components/toast";
|
||||
|
||||
import ModalDialogContainer from "../ModalDialogContainer";
|
||||
|
||||
const LogoutAllSessionDialog = ({
|
||||
t,
|
||||
exceptId,
|
||||
userIds,
|
||||
displayName,
|
||||
visible,
|
||||
isLoading,
|
||||
userIds,
|
||||
displayName,
|
||||
selection,
|
||||
bufferSelection,
|
||||
onClose,
|
||||
onClosePanel,
|
||||
onRemoveAllSessions,
|
||||
onRemoveAllExceptThis,
|
||||
isSeveralSelection,
|
||||
onLogoutAllUsers,
|
||||
onLogoutAllSessions,
|
||||
onLogoutAllExceptThis,
|
||||
setUserSessionPanelVisible,
|
||||
}) => {
|
||||
const [isChecked, setIsChecked] = useState(false);
|
||||
|
||||
const isProfile = location.pathname.includes("/profile");
|
||||
const selectionId = selection[0]?.connections[0]?.id;
|
||||
const bufferSelectionId = bufferSelection?.connections[0]?.id;
|
||||
|
||||
const exceptId = selectionId || bufferSelectionId;
|
||||
|
||||
const onChangeCheckbox = () => {
|
||||
setIsChecked((prev) => !prev);
|
||||
};
|
||||
|
||||
const onClickLogout = () => {
|
||||
if (!isChecked) {
|
||||
isSeveralSelection
|
||||
? onLogoutAllUsers(t, userIds)
|
||||
: onLogoutAllSessions(t).then(() => setUserSessionPanelVisible(false));
|
||||
onClose();
|
||||
} else {
|
||||
onLogoutAllExceptThis(t, exceptId, displayName);
|
||||
try {
|
||||
if (!isChecked) {
|
||||
isSeveralSelection
|
||||
? onLogoutAllUsers(t, userIds)
|
||||
: onLogoutAllSessions(t, userIds, displayName);
|
||||
onClosePanel();
|
||||
} else {
|
||||
onLogoutAllExceptThis(t, exceptId, displayName);
|
||||
}
|
||||
} catch (error) {
|
||||
toastr.error(error);
|
||||
} finally {
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
@ -134,10 +143,4 @@ const LogoutAllSessionDialog = ({
|
||||
);
|
||||
};
|
||||
|
||||
export default inject(({ peopleStore }) => {
|
||||
const { isSeveralSelection } = peopleStore.selectionStore;
|
||||
|
||||
return {
|
||||
isSeveralSelection,
|
||||
};
|
||||
})(observer(LogoutAllSessionDialog));
|
||||
export default LogoutAllSessionDialog;
|
||||
|
@ -100,6 +100,7 @@ const Sessions = ({
|
||||
getLoginHistoryReport,
|
||||
isLoadingDownloadReport,
|
||||
setUserSessionPanelVisible,
|
||||
isSeveralSelection,
|
||||
isSessionsLoaded,
|
||||
}) => {
|
||||
const { t } = useTranslation([
|
||||
@ -122,24 +123,12 @@ const Sessions = ({
|
||||
currentDeviceType,
|
||||
});
|
||||
|
||||
const getIdFromConnections = (connections) => connections[0]?.id;
|
||||
|
||||
const idFromSelection =
|
||||
selection.length > 0
|
||||
? getIdFromConnections(selection[0].connections)
|
||||
: undefined;
|
||||
|
||||
const idFromBufferSelection = bufferSelection
|
||||
? getIdFromConnections(bufferSelection.connections)
|
||||
: undefined;
|
||||
|
||||
const exceptId = idFromSelection || idFromBufferSelection;
|
||||
const userIdsFromSelection = selection.map((user) => user.id);
|
||||
const selectionUserId = selection.map((user) => user.id);
|
||||
|
||||
const userIds =
|
||||
bufferSelection?.id !== undefined
|
||||
? [bufferSelection.id, ...userIdsFromSelection]
|
||||
: [...userIdsFromSelection];
|
||||
? [bufferSelection.id, ...selectionUserId]
|
||||
: [...selectionUserId];
|
||||
|
||||
if (!isSessionsLoaded) return <SessionsLoader viewAs={viewAs} />;
|
||||
|
||||
@ -191,14 +180,16 @@ const Sessions = ({
|
||||
t={t}
|
||||
visible={logoutAllDialogVisible}
|
||||
isLoading={isLoading}
|
||||
exceptId={exceptId}
|
||||
userIds={userIds}
|
||||
displayName={displayName}
|
||||
selection={selection}
|
||||
bufferSelection={bufferSelection}
|
||||
isSeveralSelection={isSeveralSelection}
|
||||
onClose={() => setLogoutAllDialogVisible(false)}
|
||||
onClosePanel={() => setUserSessionPanelVisible(false)}
|
||||
onLogoutAllUsers={onClickLogoutAllUsers}
|
||||
onLogoutAllSessions={onClickLogoutAllSessions}
|
||||
onLogoutAllExceptThis={onClickLogoutAllExceptThis}
|
||||
setUserSessionPanelVisible={setUserSessionPanelVisible}
|
||||
/>
|
||||
)}
|
||||
</MainContainer>
|
||||
@ -218,6 +209,7 @@ export default inject(({ settingsStore, setup, peopleStore, dialogsStore }) => {
|
||||
selection,
|
||||
bufferSelection,
|
||||
isLoading,
|
||||
isSeveralSelection,
|
||||
onClickLogoutAllUsers,
|
||||
onClickLogoutAllSessions,
|
||||
onClickLogoutAllExceptThis,
|
||||
@ -263,6 +255,7 @@ export default inject(({ settingsStore, setup, peopleStore, dialogsStore }) => {
|
||||
getLoginHistoryReport,
|
||||
isLoadingDownloadReport,
|
||||
setUserSessionPanelVisible,
|
||||
isSeveralSelection,
|
||||
isSessionsLoaded: allSessions.length > 0,
|
||||
};
|
||||
})(observer(Sessions));
|
||||
|
@ -649,7 +649,7 @@ class SelectionStore {
|
||||
const filteredSessions = sessions.filter(
|
||||
(item) =>
|
||||
item.connections.length !== 0 &&
|
||||
item.sessions.some((session) => session.hasOwnProperty("id")),
|
||||
item.sessions?.some((session) => session.hasOwnProperty("id")),
|
||||
);
|
||||
|
||||
return filteredSessions;
|
||||
@ -672,18 +672,9 @@ class SelectionStore {
|
||||
}
|
||||
};
|
||||
|
||||
onClickLogoutAllSessions = async (t) => {
|
||||
onClickLogoutAllSessions = async (t, userId, displayName) => {
|
||||
const { removeAllActiveSessionsById } = this.settingsSetupStore;
|
||||
|
||||
const bufferSelection = this.bufferSelection?.id;
|
||||
const selection = this.selection[0]?.id;
|
||||
const userId = selection || bufferSelection;
|
||||
|
||||
if (!userId)
|
||||
return toastr.error(
|
||||
t("Settings:UserAlreadyLoggedOut", { displayName: this.displayName }),
|
||||
);
|
||||
|
||||
try {
|
||||
this.setIsLoading(true);
|
||||
await removeAllActiveSessionsById(userId);
|
||||
@ -693,12 +684,12 @@ class SelectionStore {
|
||||
sessions: [],
|
||||
};
|
||||
this.setItems(newData);
|
||||
const index = this.findSessionIndexByUserId(this.items.id);
|
||||
const index = this.findSessionIndexByUserId(userId);
|
||||
this.dataFromSocket[index] = newData;
|
||||
|
||||
toastr.success(
|
||||
t("Settings:LoggedOutByUser", {
|
||||
displayName: this.displayName,
|
||||
displayName: displayName,
|
||||
}),
|
||||
);
|
||||
} catch (error) {
|
||||
|
Loading…
Reference in New Issue
Block a user