Web: Client: Dialogs. added new parameter for resetting password on logout

This commit is contained in:
Elyor Djalilov 2024-08-26 21:01:54 +05:00
parent fbbc27ede6
commit a00be14f8e
6 changed files with 21 additions and 25 deletions

View File

@ -213,6 +213,7 @@
"QuotasDescription": "Here, you can set storage quota for users and rooms. <1>Help Center.</1>",
"Recalculate": "Recalculate",
"RecoveryFileNotSelected": "Recovery error. Recovery file not selected.",
"ResetPasswordDecription": "Reset password and send the password changing instructions to the user email",
"RestoreBackup": "Restore",
"RestoreBackupDescription": "Use this option to restore your space from the previously saved backup file.",
"RestoreBackupResetInfoWarningText": "All current passwords will be reset. {{productName}} users will get an email with the access restoration link.",

View File

@ -44,8 +44,6 @@ export const LogoutAllSessionDialog = ({
isLoading,
userIds,
displayName,
selection,
bufferSelection,
onClose,
onClosePanel,
onRemoveAllSessions,
@ -53,7 +51,6 @@ export const LogoutAllSessionDialog = ({
isSeveralSelection,
onLogoutAllUsers,
onLogoutAllSessions,
onLogoutAllExceptThis,
}: LogoutAllSessionDialogProps) => {
const [isChecked, setIsChecked] = useState(false);
const isProfile = window.location.pathname.includes("/profile");
@ -61,21 +58,10 @@ export const LogoutAllSessionDialog = ({
const onChangeCheckbox = () => setIsChecked((prev) => !prev);
const onClickLogout = () => {
const selectionId = selection[0]?.connections[0]?.id;
const bufferSelectionId = bufferSelection?.connections[0]?.id;
const exceptId = selectionId || bufferSelectionId;
try {
if (!isChecked) {
if (isSeveralSelection) {
onLogoutAllUsers(t, userIds);
} else {
onLogoutAllSessions(t, userIds, displayName);
}
if (isChecked) onLogoutAllSessions(t, userIds, displayName, isChecked);
if (!isChecked || isSeveralSelection) onLogoutAllUsers(t, userIds);
onClosePanel();
} else {
onLogoutAllExceptThis(t, exceptId, displayName);
}
} catch (error) {
toastr.error(error as TData);
} finally {
@ -105,9 +91,14 @@ export const LogoutAllSessionDialog = ({
<Text style={{ margin: "15px 0px" }}>
{t("Profile:DescriptionForSecurity")}
</Text>
<Checkbox
style={{ display: "inline-flex" }}
label={t("Profile:ChangePasswordAfterLoggingOut")}
style={{ alignItems: "flex-start" }}
label={
isProfile
? t("Profile:ChangePasswordAfterLoggingOut")
: t("Settings:ResetPasswordDecription")
}
isChecked={isChecked}
onChange={onChangeCheckbox}
/>

View File

@ -45,6 +45,7 @@ export interface LogoutAllSessionDialogProps {
t: TTranslation,
userIds: string[],
displayName: string,
isChecked: boolean,
) => void;
onLogoutAllExceptThis: (
t: TTranslation,

View File

@ -721,12 +721,12 @@ class SelectionStore {
}
};
onClickLogoutAllSessions = async (t, userId, displayName) => {
onClickLogoutAllSessions = async (t, userId, displayName, changePassword) => {
const { removeAllActiveSessionsById } = this.settingsSetupStore;
try {
this.setIsLoading(true);
await removeAllActiveSessionsById(userId);
await removeAllActiveSessionsById(userId, changePassword);
const newData = {
...this.items,

View File

@ -570,8 +570,8 @@ class SettingsSetupStore {
return api.settings.getUserSessionsById(userId);
};
removeAllActiveSessionsById = (userId) => {
return api.settings.removeAllActiveSessionsById(userId);
removeAllActiveSessionsById = (userId, changePassword) => {
return api.settings.removeAllActiveSessionsById(userId, changePassword);
};
removeAllExceptThisEventId = (userId) => {

View File

@ -895,11 +895,14 @@ export function getUserSessionsById(userId) {
});
}
export function removeAllActiveSessionsById(userId) {
export function removeAllActiveSessionsById(
userId: string,
changePassword: boolean,
) {
return request({
method: "put",
url: `/security/activeconnections/logoutall/${userId}`,
data: { userId },
data: { userId, changePassword },
});
}