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