From 08d7647bbe36572f83e70b83cc44c3a230120da0 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 6 Apr 2022 12:24:35 +0300 Subject: [PATCH 01/64] Web: Client: add settings translates --- web/ASC.Web.Client/public/locales/en/Settings.json | 5 +++++ web/ASC.Web.Client/public/locales/ru/Settings.json | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/web/ASC.Web.Client/public/locales/en/Settings.json b/web/ASC.Web.Client/public/locales/en/Settings.json index c8ead7d735..536f3573c3 100644 --- a/web/ASC.Web.Client/public/locales/en/Settings.json +++ b/web/ASC.Web.Client/public/locales/en/Settings.json @@ -15,6 +15,7 @@ "AutoBackupHelpNote": "Choose the data storage, automatic backup period and maximal number of saved copies.
Note: before you can save the backup data to a third-party account (DropBox, Box.com, OneDrive or Google Drive), you will need to connect this account to {{organizationName}} Common folder.", "AutoSavePeriod": "Autosave period", "AddAdmins": "Add admins", + "AddAllowedIP": "Add allowed IP address", "AddName": "Add Name", "AdminInModules": "Admin in modules", "AdministratorsAddedSuccessfully": "Administrators added successfully", @@ -65,6 +66,10 @@ "GroupLead": "Group Lead", "Groups": "Groups", "Guests": "Guests", + "IPSecurity": "IP Security", + "IPSecurityDescription": "IP Security is used to restrict login to the portal from all IP addresses except certain addresses.", + "IPSecurityHelper": "You can set the allowed IP addresses using either exact IP addresses in the IPv4 format (#.#.#.#, where # is a numeric value from 0 to 255) or IP range (in the #.#.#.#-#.#.#.# format).", + "IPSecurityWarningHelper": "First you need to specify your current IP or the IP range your current IP address belongs to, otherwise your portal access will be blocked right after you save the settings. The portal owner will have the portal access from any IP address.", "Job/Title": "Job/Title", "LanguageAndTimeZoneSettingsDescription": "Language and Time Zone Settings is a way to change the language of the whole portal for all portal users and to configure the time zone so that all the events of the ©linney portal will be shown with the correct date and time.", "LanguageTimeSettingsTooltip": "<0>{{text}} is a way to change the language of the whole portal for all portal users and to configure the time zone so that all the events of the ONLYOFFICE portal will be shown with the correct date and time.", diff --git a/web/ASC.Web.Client/public/locales/ru/Settings.json b/web/ASC.Web.Client/public/locales/ru/Settings.json index 2d1b9ad029..045983d259 100644 --- a/web/ASC.Web.Client/public/locales/ru/Settings.json +++ b/web/ASC.Web.Client/public/locales/ru/Settings.json @@ -16,6 +16,7 @@ "AutoSavePeriod": "Период автоматического сохранения", "AutoSavePeriodHelp": "Указанное ниже время соотвествует часовому поясу, выставленному на портале", "AddAdmins": "Добавить администраторов", + "AddAllowedIP": "Добавить разрешенный IP-адрес", "AddName": "Добавьте наименование", "AdminInModules": "Администратор в модулях", "AdministratorsAddedSuccessfully": "Администраторы успешно добавлены", @@ -66,6 +67,10 @@ "GroupLead": "Руководитель группы", "Groups": "Группы", "Guests": "Гости", + "IPSecurity": "IP-безопасность", + "IPSecurityDescription": "Настройки IP-безопасности используются для ограничения возможности входа на портал со всех IP-адресов, кроме указанных.", + "IPSecurityHelper": "Вы можете задать разрешенные IP-адреса, указав конкретные значения IP-адресов в формате IPv4 (#.#.#.#, где # - это число от 0 до 255) или диапазон IP-адресов (в формате #.#.#.#-#.#.#.#).", + "IPSecurityWarningHelper": "Первым необходимо указать ваш текущий IP-адрес или диапазон IP-адресов, в который входит ваш текущий IP, иначе после сохранения настроек Вам будет заблокирован доступ к порталу. Владелец портала будет иметь доступ с любого IP-адреса.", "Job/Title": "Должность/Позиция", "LanguageAndTimeZoneSettingsDescription": "Настройки языка и часового пояса позволяют изменить язык всего портала для всех пользователей и настроить часовой пояс, чтобы все события на портале ©linney отображались с корректной датой и временем.", "LanguageTimeSettingsTooltip": "<0>{{text}} позволяют изменить язык всего портала для всех пользователей и настроить часовой пояс, чтобы все события на портале ONLYOFFICE отображались с корректной датой и временем.", From d6e317e7d3233c71d8892e9fe22e9c32c657a468 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 6 Apr 2022 12:35:38 +0300 Subject: [PATCH 02/64] Web: Client: Settings: init ip security setting --- .../Settings/categories/security/access-portal/index.js | 7 +++++++ .../categories/security/access-portal/ipSecurity.js | 7 +++++++ .../categories/security/access-portal/mobileView.js | 6 ++++++ web/ASC.Web.Client/src/components/pages/Settings/index.js | 8 ++++++++ .../src/components/pages/Settings/utils/settingsTree.js | 6 ++++++ 5 files changed, 34 insertions(+) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js index 732fb8cd3d..46a2ba2932 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js @@ -7,6 +7,7 @@ import { MainContainer } from "../StyledSecurity"; import TfaSection from "./tfa"; import PasswordStrengthSection from "./passwordStrength"; import TrustedMailSection from "./trustedMail"; +import IpSecuritySection from "./ipSecurity"; import MobileView from "./mobileView"; import CategoryWrapper from "../sub-components/category-wrapper"; import { size } from "@appserver/components/utils/device"; @@ -49,6 +50,12 @@ const AccessPortal = (props) => { tooltipContent={t("TrustedMailDescription")} /> +
+ + ); }; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js new file mode 100644 index 0000000000..2df49c4040 --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js @@ -0,0 +1,7 @@ +import React from "react"; + +const IpSecurity = () => { + return

IP

; +}; + +export default IpSecurity; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js index 24881450d5..b58ba22217 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js @@ -37,6 +37,12 @@ const MobileView = (props) => { url="/settings/security/access-portal/trusted-mail" onClickLink={onClickLink} /> + ); }; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/index.js b/web/ASC.Web.Client/src/components/pages/Settings/index.js index 9c199c0ad4..393dd6a077 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/index.js @@ -14,6 +14,9 @@ const PasswordStrengthPage = lazy(() => const TrustedMailPage = lazy(() => import("./categories/security/access-portal/trustedMail") ); +const IpSecurityPage = lazy(() => + import("./categories/security/access-portal/ipSecurity") +); const CommonSettings = lazy(() => import("./categories/common/index.js")); @@ -92,6 +95,10 @@ const TRUSTED_MAIL_PAGE_URL = combineUrl( PROXY_BASE_URL, "/security/access-portal/trusted-mail" ); +const IP_SECURITY_PAGE_URL = combineUrl( + PROXY_BASE_URL, + "/security/access-portal/ip" +); const ADMINS_URL = combineUrl(PROXY_BASE_URL, "/security/access-rights/admins"); const THIRD_PARTY_URL = combineUrl( @@ -140,6 +147,7 @@ const Settings = () => { path={TRUSTED_MAIL_PAGE_URL} component={TrustedMailPage} /> + Date: Wed, 6 Apr 2022 14:08:52 +0300 Subject: [PATCH 03/64] Web: Common: API: fix, add getIpRestrictions --- packages/asc-web-common/api/settings/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/asc-web-common/api/settings/index.js b/packages/asc-web-common/api/settings/index.js index 0f2bd0af5f..a893900d9c 100644 --- a/packages/asc-web-common/api/settings/index.js +++ b/packages/asc-web-common/api/settings/index.js @@ -54,10 +54,17 @@ export function setDNSSettings(dnsName, enable) { }); } +export function getIpRestrictions() { + return request({ + method: "get", + url: "/settings/iprestrictions", + }); +} + export function setIpRestrictions(data) { return request({ method: "put", - url: "/settings/iprestrictions.json", + url: "/settings/iprestrictions", data, }); } @@ -65,7 +72,7 @@ export function setIpRestrictions(data) { export function setIpRestrictionsEnable(data) { return request({ method: "put", - url: "/settings/iprestrictions/settings.json", + url: "/settings/iprestrictions/settings", data, }); } From fffb843ae6344cb38938200dc767b255535bd6d3 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 6 Apr 2022 14:09:26 +0300 Subject: [PATCH 04/64] Web: Common: add ipRestriction in store --- packages/asc-web-common/store/AuthStore.js | 1 + .../asc-web-common/store/SettingsStore.js | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/packages/asc-web-common/store/AuthStore.js b/packages/asc-web-common/store/AuthStore.js index 0d538a7019..37e728876d 100644 --- a/packages/asc-web-common/store/AuthStore.js +++ b/packages/asc-web-common/store/AuthStore.js @@ -55,6 +55,7 @@ class AuthStore { if (this.isAuthenticated) { this.settingsStore.getPortalPasswordSettings(); this.tfaStore.getTfaType(); + this.settingsStore.getIpRestrictions(); } return Promise.all(requests); diff --git a/packages/asc-web-common/store/SettingsStore.js b/packages/asc-web-common/store/SettingsStore.js index a1f3c27c4f..7086f6ef2f 100644 --- a/packages/asc-web-common/store/SettingsStore.js +++ b/packages/asc-web-common/store/SettingsStore.js @@ -31,6 +31,8 @@ class SettingsStore { : Base; trustedDomains = []; trustedDomainsType = 0; + ipRestrictionEnable = false; + ipRestrictions = []; timezone = "UTC"; timezones = []; utcOffset = "00:00:00"; @@ -449,6 +451,30 @@ class SettingsStore { this.trustedDomains = data.domains; return res; }; + + getIpRestrictions = async () => { + const res = await api.settings.getIpRestrictions(); + if (res.length === 0) this.ipRestrictionEnabled = false; + else this.ipRestrictionEnabled = true; + }; + + setIpRestrictions = async (ips) => { + const data = { + ips: ips, + }; + const res = await api.settings.setIpRestrictions(data); + console.log("setIpRestrictions", res); + this.ipRestrictions = ips; + }; + + setIpRestrictionsEnable = async (enable) => { + const data = { + enable: enable, + }; + const res = await api.settings.setIpRestrictionsEnable(data); + console.log("setIpRestrictionsEnable", res); + this.ipRestrictionEnabled = enable; + }; } export default SettingsStore; From ae3aff5576c920197df2c68131d24730018517c9 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 6 Apr 2022 14:09:52 +0300 Subject: [PATCH 05/64] Web: Client: delete useless --- web/ASC.Web.Client/src/store/SettingsSetupStore.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/web/ASC.Web.Client/src/store/SettingsSetupStore.js b/web/ASC.Web.Client/src/store/SettingsSetupStore.js index cc2dc565ab..29569fc270 100644 --- a/web/ASC.Web.Client/src/store/SettingsSetupStore.js +++ b/web/ASC.Web.Client/src/store/SettingsSetupStore.js @@ -231,14 +231,6 @@ class SettingsSetupStore { const res = await api.settings.setMailDomainSettings(dnsName, enable); }; - setIpRestrictions = async (data) => { - const res = await api.settings.setIpRestrictions(data); - }; - - setIpRestrictionsEnable = async (data) => { - const res = await api.settings.setIpRestrictionsEnable(data); - }; - setMessageSettings = async (turnOn) => { const res = await api.settings.setMessageSettings(turnOn); }; From fa397a1511eee08a0d4dc766e162e88087a89ca1 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 6 Apr 2022 14:13:15 +0300 Subject: [PATCH 06/64] Web: Client: Settings: ipSecurity add layout and logic --- .../security/access-portal/ipSecurity.js | 226 +++++++++++++++++- 1 file changed, 222 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js index 2df49c4040..a4bddcff38 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js @@ -1,7 +1,225 @@ -import React from "react"; +import React, { useState, useEffect } from "react"; +import styled from "styled-components"; +import { withRouter } from "react-router"; +import { withTranslation } from "react-i18next"; +import { inject, observer } from "mobx-react"; +import Text from "@appserver/components/text"; +import RadioButtonGroup from "@appserver/components/radio-button-group"; +import toastr from "@appserver/components/toast/toastr"; +import { LearnMoreWrapper } from "../StyledSecurity"; +import UserFields from "../sub-components/user-fields"; +import Buttons from "../sub-components/buttons"; +import { size } from "@appserver/components/utils/device"; +import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; +import isEqual from "lodash/isEqual"; -const IpSecurity = () => { - return

IP

; +const MainContainer = styled.div` + width: 100%; + + .page-subtitle { + margin-bottom: 10px; + } + + .user-fields { + margin-bottom: 18px; + } + + .box { + margin-bottom: 11px; + } + + .warning-text { + margin-bottom: 9px; + } +`; + +const IpSecurity = (props) => { + const { + t, + history, + ipRestrictionEnabled, + setIpRestrictionsEnable, + ipRestrictions, + setIpRestrictions, + } = props; + + const regexp = /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))|((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])/; //check ip valid + + const [enable, setEnable] = useState(false); + const [ips, setIps] = useState(); + const [showReminder, setShowReminder] = useState(false); + const [isLoading, setIsLoading] = useState(false); + + const getSettings = () => { + const currentSettings = getFromSessionStorage("currentIPSettings"); + const defaultSettings = getFromSessionStorage("defaultIPSettings"); + + if (defaultSettings) { + saveToSessionStorage("defaultIPSettings", defaultSettings); + } else { + const defaultData = { + enable: ipRestrictionEnabled, + ips: ipRestrictions, + }; + saveToSessionStorage("defaultIPSettings", defaultData); + } + + if (currentSettings) { + setEnable(currentSettings.enable); + setIps(currentSettings.ips); + } else { + setEnable(ipRestrictionEnabled); + setIps(ipRestrictions); + } + + setIsLoading(true); + }; + + useEffect(() => { + checkWidth(); + getSettings(); + window.addEventListener("resize", checkWidth); + return () => window.removeEventListener("resize", checkWidth); + }, [isLoading]); + + useEffect(() => { + if (!isLoading) return; + + const defaultSettings = getFromSessionStorage("defaultIPSettings"); + const newSettings = { + enable: enable, + ips: ips, + }; + saveToSessionStorage("currentIPSettings", newSettings); + + if (isEqual(defaultSettings, newSettings)) { + setShowReminder(false); + } else { + setShowReminder(true); + } + }, [enable, ips]); + + const checkWidth = () => { + window.innerWidth > size.smallTablet && + history.location.pathname.includes("ip") && + history.push("/settings/security/access-portal"); + }; + + const onSelectType = (e) => { + setEnable(e.target.value === "enable" ? true : false); + }; + + const onChangeInput = (e, index) => { + let newInputs = Array.from(ips); + newInputs[index] = e.target.value; + setIps(newInputs); + }; + + const onDeleteInput = (index) => { + let newInputs = Array.from(ips); + newInputs.splice(index, 1); + setIps(newInputs); + }; + + const onClickAdd = () => { + setIps([...ips, ""]); + }; + + const onSaveClick = () => { + const valid = ips.map((ip) => regexp.test(ip)); + if (valid.includes(false)) { + return; + } + + setIpRestrictions(ips); + setIpRestrictionsEnable(enable); + + saveToSessionStorage("defaultIPSettings", { + enable: enable, + ips: ips, + }); + setShowReminder(false); + toastr.success(t("SuccessfullySaveSettingsMessage")); + }; + + const onCancelClick = () => { + const defaultSettings = getFromSessionStorage("defaultIPSettings"); + setEnable(defaultSettings.enable); + setIps(defaultSettings.ips); + setShowReminder(false); + }; + + return ( + + + {t("IPSecurityHelper")} + + + + + {enable && ( + + )} + + + {t("Common:Warning")}! + + {t("IPSecurityWarningHelper")} + + + + ); }; -export default IpSecurity; +export default inject(({ auth }) => { + const { + ipRestrictionEnabled, + setIpRestrictionsEnable, + ipRestrictions, + setIpRestrictions, + } = auth.settingsStore; + + return { + ipRestrictionEnabled, + setIpRestrictionsEnable, + ipRestrictions, + setIpRestrictions, + }; +})(withTranslation(["Settings", "Common"])(withRouter(observer(IpSecurity)))); From 92899d14dfe47684747f851581e6aa88f97fbefc Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 6 Apr 2022 17:04:49 +0300 Subject: [PATCH 07/64] Web: Client: add settings translate --- web/ASC.Web.Client/public/locales/en/Settings.json | 3 +++ web/ASC.Web.Client/public/locales/ru/Settings.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/web/ASC.Web.Client/public/locales/en/Settings.json b/web/ASC.Web.Client/public/locales/en/Settings.json index 536f3573c3..5e02f1025b 100644 --- a/web/ASC.Web.Client/public/locales/en/Settings.json +++ b/web/ASC.Web.Client/public/locales/en/Settings.json @@ -21,6 +21,9 @@ "AdministratorsAddedSuccessfully": "Administrators added successfully", "AdministratorsRemovedSuccessfully": "Administrators removed successfully", "Admins": "Admins", + "AdminsMessage": "Administrator Message Settings", + "AdminsMessageDescription": "Administrator Message Settings is a way to contact the portal administrator.", + "AdminsMessageHelper": "Enable this option to display the contact form on the Sign In page so that people could send the message to the portal administrator in case they have troubles accessing the portal.", "AllDomains": "Any domains", "Backup": "Backup", "BackupCreatedSuccess": "The backup copy has been successfully created.", diff --git a/web/ASC.Web.Client/public/locales/ru/Settings.json b/web/ASC.Web.Client/public/locales/ru/Settings.json index 045983d259..a78371c5c8 100644 --- a/web/ASC.Web.Client/public/locales/ru/Settings.json +++ b/web/ASC.Web.Client/public/locales/ru/Settings.json @@ -22,6 +22,9 @@ "AdministratorsAddedSuccessfully": "Администраторы успешно добавлены", "AdministratorsRemovedSuccessfully": "Администраторы успешно удалены", "Admins": "Администраторы", + "AdminsMessage": "Настройки сообщений администратору", + "AdminsMessageDescription": "Настройки сообщений администратору это способ связаться с администратором портала.", + "AdminsMessageHelper": "Включите эту опцию для отображения формы связи на странице Входа, чтобы пользователи могли отправить сообщение администратору портала в случае, если у них возникают проблемы со входом на портал.", "AllDomains": "Любые домены", "Backup": "Резервное копирование", "BackupCreatedSuccess": "Резервная копия успешно создана.", From 8efae2617d3f0bc93e692fe78c53221f7a50b2e7 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 6 Apr 2022 17:10:49 +0300 Subject: [PATCH 08/64] Web: Client: Settings: init admin message setting --- .../security/access-portal/adminMessage.js | 7 +++++++ .../categories/security/access-portal/index.js | 7 +++++++ .../categories/security/access-portal/mobileView.js | 6 ++++++ .../src/components/pages/Settings/index.js | 12 ++++++++++++ .../components/pages/Settings/utils/settingsTree.js | 6 ++++++ 5 files changed, 38 insertions(+) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js new file mode 100644 index 0000000000..42d893d9c8 --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -0,0 +1,7 @@ +import React from "react"; + +const AdminMessage = () => { + return

Admin message

; +}; + +export default AdminMessage; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js index 46a2ba2932..094173db4f 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js @@ -8,6 +8,7 @@ import TfaSection from "./tfa"; import PasswordStrengthSection from "./passwordStrength"; import TrustedMailSection from "./trustedMail"; import IpSecuritySection from "./ipSecurity"; +import AdminMessageSection from "./adminMessage"; import MobileView from "./mobileView"; import CategoryWrapper from "../sub-components/category-wrapper"; import { size } from "@appserver/components/utils/device"; @@ -56,6 +57,12 @@ const AccessPortal = (props) => { tooltipContent={t("IPSecurityDescription")} /> +
+ + ); }; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js index b58ba22217..c0b865410b 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js @@ -43,6 +43,12 @@ const MobileView = (props) => { url="/settings/security/access-portal/ip" onClickLink={onClickLink} /> + ); }; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/index.js b/web/ASC.Web.Client/src/components/pages/Settings/index.js index 393dd6a077..4b3aa6b1ba 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/index.js @@ -17,6 +17,9 @@ const TrustedMailPage = lazy(() => const IpSecurityPage = lazy(() => import("./categories/security/access-portal/ipSecurity") ); +const AdminMessagePage = lazy(() => + import("./categories/security/access-portal/adminMessage") +); const CommonSettings = lazy(() => import("./categories/common/index.js")); @@ -99,6 +102,10 @@ const IP_SECURITY_PAGE_URL = combineUrl( PROXY_BASE_URL, "/security/access-portal/ip" ); +const ADMIN_MESSAGE_PAGE_URL = combineUrl( + PROXY_BASE_URL, + "/security/access-portal/admin-message" +); const ADMINS_URL = combineUrl(PROXY_BASE_URL, "/security/access-rights/admins"); const THIRD_PARTY_URL = combineUrl( @@ -148,6 +155,11 @@ const Settings = () => { component={TrustedMailPage} /> + Date: Thu, 7 Apr 2022 04:02:34 +0300 Subject: [PATCH 09/64] Web: Common: SettingsStore: add setMessageSettings --- packages/asc-web-common/store/SettingsStore.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/asc-web-common/store/SettingsStore.js b/packages/asc-web-common/store/SettingsStore.js index 7086f6ef2f..732efdb206 100644 --- a/packages/asc-web-common/store/SettingsStore.js +++ b/packages/asc-web-common/store/SettingsStore.js @@ -475,6 +475,11 @@ class SettingsStore { console.log("setIpRestrictionsEnable", res); this.ipRestrictionEnabled = enable; }; + + setMessageSettings = async (turnOn) => { + await api.settings.setMessageSettings(turnOn); + this.enableAdmMess = turnOn; + }; } export default SettingsStore; From b07ebbce3bbda48f9b5884358c67f5620665962a Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 7 Apr 2022 04:02:53 +0300 Subject: [PATCH 10/64] Web: Client: delete useless --- web/ASC.Web.Client/src/store/SettingsSetupStore.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/web/ASC.Web.Client/src/store/SettingsSetupStore.js b/web/ASC.Web.Client/src/store/SettingsSetupStore.js index 29569fc270..714be53421 100644 --- a/web/ASC.Web.Client/src/store/SettingsSetupStore.js +++ b/web/ASC.Web.Client/src/store/SettingsSetupStore.js @@ -231,10 +231,6 @@ class SettingsSetupStore { const res = await api.settings.setMailDomainSettings(dnsName, enable); }; - setMessageSettings = async (turnOn) => { - const res = await api.settings.setMessageSettings(turnOn); - }; - setCookieSettings = async (lifeTime) => { const res = await api.settings.setCookieSettings(lifeTime); }; From a44eaa9ea5fe49f8fbf74b3ec6eea7d08eaa8a37 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 7 Apr 2022 04:03:37 +0300 Subject: [PATCH 11/64] Web: Client: Settings: add admin message setting layout, logic --- .../security/access-portal/adminMessage.js | 155 +++++++++++++++++- 1 file changed, 151 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index 42d893d9c8..14b04d00f6 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -1,7 +1,154 @@ -import React from "react"; +import React, { useState, useEffect } from "react"; +import styled from "styled-components"; +import { withRouter } from "react-router"; +import { withTranslation } from "react-i18next"; +import { inject, observer } from "mobx-react"; +import RadioButtonGroup from "@appserver/components/radio-button-group"; +import Text from "@appserver/components/text"; +import Link from "@appserver/components/link"; +import toastr from "@appserver/components/toast/toastr"; +import SectionLoader from "../sub-components/section-loader"; +import { getLanguage } from "@appserver/common/utils"; +import Buttons from "../sub-components/buttons"; +import { LearnMoreWrapper } from "../StyledSecurity"; +import { size } from "@appserver/components/utils/device"; +import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; -const AdminMessage = () => { - return

Admin message

; +const MainContainer = styled.div` + width: 100%; + + .page-subtitle { + margin-bottom: 10px; + } +`; + +const AdminMessage = (props) => { + const { t, history, enableAdmMess, setMessageSettings } = props; + const [type, setType] = useState(false); + const [showReminder, setShowReminder] = useState(false); + const [isLoading, setIsLoading] = useState(false); + + const getSettings = () => { + const currentSettings = getFromSessionStorage( + "currentAdminMessageSettings" + ); + const defaultSettings = getFromSessionStorage( + "defaultAdminMessageSettings" + ); + + if (defaultSettings) { + saveToSessionStorage("defaultAdminMessageSettings", defaultSettings); + } else { + saveToSessionStorage("defaultAdminMessageSettings", enableAdmMess); + } + + if (currentSettings) { + setType(currentSettings); + } else { + setType(enableAdmMess); + } + setIsLoading(true); + }; + + useEffect(() => { + checkWidth(); + getSettings(); + window.addEventListener("resize", checkWidth); + return () => window.removeEventListener("resize", checkWidth); + }, [isLoading]); + + useEffect(() => { + if (!isLoading) return; + + const defaultSettings = getFromSessionStorage( + "defaultAdminMessageSettings" + ); + saveToSessionStorage("currentAdminMessageSettings", type); + + if (defaultSettings === type) { + setShowReminder(false); + } else { + setShowReminder(true); + } + }, [type]); + + const checkWidth = () => { + window.innerWidth > size.smallTablet && + history.location.pathname.includes("admin-message") && + history.push("/settings/security/access-portal"); + }; + + const onSelectType = (e) => { + setType(e.target.value === "enable" ? true : false); + }; + + const onSaveClick = () => { + setMessageSettings(type); + toastr.success(t("SuccessfullySaveSettingsMessage")); + saveToSessionStorage("defaultAdminMessageSettings", type); + setShowReminder(false); + }; + + const onCancelClick = () => { + const defaultSettings = getFromSessionStorage( + "defaultAdminMessageSettings" + ); + setType(defaultSettings); + setShowReminder(false); + }; + + const lng = getLanguage(localStorage.getItem("language") || "en"); + if (!isLoading) return ; + return ( + + + {t("AdminsMessageHelper")} + + {t("Common:LearnMore")} + + + + + + + + ); }; -export default AdminMessage; +export default inject(({ auth }) => { + const { enableAdmMess, setMessageSettings } = auth.settingsStore; + + return { + enableAdmMess, + setMessageSettings, + }; +})(withTranslation(["Settings", "Common"])(withRouter(observer(AdminMessage)))); From c7a8ca73090d69cfcc2d0d47cf487f7bbefb3a36 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 7 Apr 2022 17:27:52 +0300 Subject: [PATCH 12/64] Web: Client: Settings: fix category wrapper --- .../categories/security/access-portal/index.js | 2 ++ .../security/sub-components/category-wrapper.js | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js index 6b2b1704e2..e23bdb157f 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js @@ -61,8 +61,10 @@ const AccessPortal = (props) => {
diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/category-wrapper.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/category-wrapper.js index 3f6bc63f74..2530ddbdf9 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/category-wrapper.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/category-wrapper.js @@ -10,10 +10,12 @@ const CategoryWrapper = (props) => { const tooltip = () => ( - {tooltipTitle} - - {t("Common:LearnMore")} - + {tooltipTitle} + {tooltipUrl && ( + + {t("Common:LearnMore")} + + )} ); From ae8da903a80b039016b405e235dfc08c3c7d8078 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 7 Apr 2022 17:33:58 +0300 Subject: [PATCH 13/64] Web: Client: Settings: fix category wrapper --- .../categories/security/access-portal/adminMessage.js | 3 +-- .../pages/Settings/categories/security/access-portal/index.js | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index 14b04d00f6..b504a94320 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -7,7 +7,6 @@ import RadioButtonGroup from "@appserver/components/radio-button-group"; import Text from "@appserver/components/text"; import Link from "@appserver/components/link"; import toastr from "@appserver/components/toast/toastr"; -import SectionLoader from "../sub-components/section-loader"; import { getLanguage } from "@appserver/common/utils"; import Buttons from "../sub-components/buttons"; import { LearnMoreWrapper } from "../StyledSecurity"; @@ -98,7 +97,7 @@ const AdminMessage = (props) => { }; const lng = getLanguage(localStorage.getItem("language") || "en"); - if (!isLoading) return ; + return ( diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js index f4577a03c1..a14ce05e28 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js @@ -70,8 +70,10 @@ const AccessPortal = (props) => {
From 74f4ade853dc338543e03b6e1ab42ddf13a7e6ae Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 7 Apr 2022 17:41:24 +0300 Subject: [PATCH 14/64] Web: Client: add settings translate --- web/ASC.Web.Client/public/locales/en/Settings.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/ASC.Web.Client/public/locales/en/Settings.json b/web/ASC.Web.Client/public/locales/en/Settings.json index 999ec4a9e4..23d545d58e 100644 --- a/web/ASC.Web.Client/public/locales/en/Settings.json +++ b/web/ASC.Web.Client/public/locales/en/Settings.json @@ -78,6 +78,7 @@ "LanguageTimeSettingsTooltip": "<0>{{text}} is a way to change the language of the whole portal for all portal users and to configure the time zone so that all the events of the ONLYOFFICE portal will be shown with the correct date and time.", "LocalFile": "Local file", "LanguageTimeSettingsTooltipDescription": "To make the parameters you set take effect click the <1>{{save}} button at the bottom of the section.<3>{{learnMore}}", + "Lifetime": "Lifetime (min)", "LogoDark": "Logo for the About/Login page", "LogoDocsEditor": "Logo for the editors header", "LogoFavicon": "Favicon", @@ -124,6 +125,9 @@ "RestoreBackupHelpNote": "Select the storage where the data is saved, enter necessary details and check the Send notification to portal users to alert your portal users about the backup/restore operations.", "RestoreDefaultButton": "Restore to Default", "RecoveryFileNotSelected": "Recovery error. Recovery file not selected", + "SessionLifetime": "Session Lifetime", + "SessionLifetimeDescription": "Session Lifetime allows to set time (in minutes) before the portal users will need to enter the portal credentials again in order to access the portal.", + "SessionLifetimeHelper": "After save all the users will be logged out from portal.", "SetDefaultTitle": "Set default title", "SettingPasswordStrength": "Setting password strength", "SettingPasswordStrengthDescription": "Password Strength Settings is a way to determine the effectiveness of a password in resisting guessing and brute-force attacks.", From a77ef07e8ec189a478737b24d43665c035d693e7 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 7 Apr 2022 17:46:43 +0300 Subject: [PATCH 15/64] Web: Client: Settings: init session lifetime --- .../categories/security/access-portal/index.js | 9 +++++++++ .../categories/security/access-portal/mobileView.js | 6 ++++++ .../security/access-portal/sessionLifetime.js | 7 +++++++ .../src/components/pages/Settings/index.js | 12 ++++++++++++ .../components/pages/Settings/utils/settingsTree.js | 6 ++++++ 5 files changed, 40 insertions(+) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js index a14ce05e28..c3894808d1 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js @@ -9,6 +9,7 @@ import PasswordStrengthSection from "./passwordStrength"; import TrustedMailSection from "./trustedMail"; import IpSecuritySection from "./ipSecurity"; import AdminMessageSection from "./adminMessage"; +import SessionLifetimeSection from "./sessionLifetime"; import MobileView from "./mobileView"; import CategoryWrapper from "../sub-components/category-wrapper"; import { size } from "@appserver/components/utils/device"; @@ -76,6 +77,14 @@ const AccessPortal = (props) => { tooltipUrl={`https://helpcenter.onlyoffice.com/${lng}/administration/configuration.aspx#ChangingSecuritySettings_block`} /> + +
+ + ); }; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js index c0b865410b..c1a073da52 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/mobileView.js @@ -49,6 +49,12 @@ const MobileView = (props) => { url="/settings/security/access-portal/admin-message" onClickLink={onClickLink} /> + ); }; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js new file mode 100644 index 0000000000..0ba7f2c4ae --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js @@ -0,0 +1,7 @@ +import React from "react"; + +const SessionLifetime = () => { + return

Session lifetime

; +}; + +export default SessionLifetime; diff --git a/web/ASC.Web.Client/src/components/pages/Settings/index.js b/web/ASC.Web.Client/src/components/pages/Settings/index.js index 4b3aa6b1ba..cf9f71f8bc 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/index.js @@ -20,6 +20,9 @@ const IpSecurityPage = lazy(() => const AdminMessagePage = lazy(() => import("./categories/security/access-portal/adminMessage") ); +const SessionLifetimePage = lazy(() => + import("./categories/security/access-portal/sessionLifetime") +); const CommonSettings = lazy(() => import("./categories/common/index.js")); @@ -106,6 +109,10 @@ const ADMIN_MESSAGE_PAGE_URL = combineUrl( PROXY_BASE_URL, "/security/access-portal/admin-message" ); +const SESSION_LIFETIME_PAGE_URL = combineUrl( + PROXY_BASE_URL, + "/security/access-portal/lifetime" +); const ADMINS_URL = combineUrl(PROXY_BASE_URL, "/security/access-rights/admins"); const THIRD_PARTY_URL = combineUrl( @@ -160,6 +167,11 @@ const Settings = () => { path={ADMIN_MESSAGE_PAGE_URL} component={AdminMessagePage} /> + Date: Thu, 7 Apr 2022 17:55:14 +0300 Subject: [PATCH 16/64] Web: Client: Settings: delete useless --- web/ASC.Web.Client/src/store/SettingsSetupStore.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/web/ASC.Web.Client/src/store/SettingsSetupStore.js b/web/ASC.Web.Client/src/store/SettingsSetupStore.js index 714be53421..023f54952e 100644 --- a/web/ASC.Web.Client/src/store/SettingsSetupStore.js +++ b/web/ASC.Web.Client/src/store/SettingsSetupStore.js @@ -231,10 +231,6 @@ class SettingsSetupStore { const res = await api.settings.setMailDomainSettings(dnsName, enable); }; - setCookieSettings = async (lifeTime) => { - const res = await api.settings.setCookieSettings(lifeTime); - }; - setLifetimeAuditSettings = async (data) => { const res = await api.settings.setLifetimeAuditSettings(data); }; From 883cc628ea0e1e49bb69ffa173fcded73c680df7 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 7 Apr 2022 17:55:44 +0300 Subject: [PATCH 17/64] Web: Common: add session lifetime --- packages/asc-web-common/api/settings/index.js | 7 +++++++ packages/asc-web-common/store/AuthStore.js | 1 + packages/asc-web-common/store/SettingsStore.js | 11 +++++++++++ 3 files changed, 19 insertions(+) diff --git a/packages/asc-web-common/api/settings/index.js b/packages/asc-web-common/api/settings/index.js index a893900d9c..2463e98c66 100644 --- a/packages/asc-web-common/api/settings/index.js +++ b/packages/asc-web-common/api/settings/index.js @@ -93,6 +93,13 @@ export function setCookieSettings(lifeTime) { }); } +export function getCookieSettings() { + return request({ + method: "get", + url: "/settings/cookiesettings.json", + }); +} + export function setLifetimeAuditSettings(data) { return request({ method: "post", diff --git a/packages/asc-web-common/store/AuthStore.js b/packages/asc-web-common/store/AuthStore.js index 37e728876d..97cf0f33ca 100644 --- a/packages/asc-web-common/store/AuthStore.js +++ b/packages/asc-web-common/store/AuthStore.js @@ -56,6 +56,7 @@ class AuthStore { this.settingsStore.getPortalPasswordSettings(); this.tfaStore.getTfaType(); this.settingsStore.getIpRestrictions(); + this.settingsStore.getSessionLifetime(); } return Promise.all(requests); diff --git a/packages/asc-web-common/store/SettingsStore.js b/packages/asc-web-common/store/SettingsStore.js index 732efdb206..bdd55ae45e 100644 --- a/packages/asc-web-common/store/SettingsStore.js +++ b/packages/asc-web-common/store/SettingsStore.js @@ -33,6 +33,7 @@ class SettingsStore { trustedDomainsType = 0; ipRestrictionEnable = false; ipRestrictions = []; + sessionLifetime = "1440"; timezone = "UTC"; timezones = []; utcOffset = "00:00:00"; @@ -480,6 +481,16 @@ class SettingsStore { await api.settings.setMessageSettings(turnOn); this.enableAdmMess = turnOn; }; + + getSessionLifetime = async () => { + const res = await api.settings.getSessionLifetime(); + this.sessionLifetime = res; + }; + + setSessionLifetimeSettings = async (lifeTime) => { + const res = await api.settings.setCookieSettings(lifeTime); + this.sessionLifetime = lifeTime; + }; } export default SettingsStore; From 7e5e4f5c48f39d86397861529beaec183d9e716c Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 7 Apr 2022 18:19:57 +0300 Subject: [PATCH 18/64] Web: Client: Settings: add session lifetime layout --- .../security/access-portal/sessionLifetime.js | 102 +++++++++++++++++- 1 file changed, 98 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js index 0ba7f2c4ae..c012fa1140 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js @@ -1,7 +1,101 @@ -import React from "react"; +import React, { useState, useEffect } from "react"; +import styled from "styled-components"; +import { withRouter } from "react-router"; +import { withTranslation } from "react-i18next"; +import { inject, observer } from "mobx-react"; +import RadioButtonGroup from "@appserver/components/radio-button-group"; +import Text from "@appserver/components/text"; +import TextInput from "@appserver/components/text-input"; +import toastr from "@appserver/components/toast/toastr"; +import Buttons from "../sub-components/buttons"; +import { LearnMoreWrapper } from "../StyledSecurity"; +import { size } from "@appserver/components/utils/device"; +import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; -const SessionLifetime = () => { - return

Session lifetime

; +const MainContainer = styled.div` + width: 100%; + + .lifetime { + margin-top: 16px; + margin-bottom: 8px; + } +`; + +const SessionLifetime = (props) => { + const { t } = props; + const [type, setType] = useState(false); + const [sessionLifetime, setSessionLifetime] = useState("0"); + const [showReminder, setShowReminder] = useState(false); + + const onSelectType = (e) => { + setType(e.target.value === "enable" ? true : false); + }; + + const onChangeInput = (e) => { + setSessionLifetime(e.target.value); + }; + + const onSaveClick = () => {}; + + const onCancelClick = () => {}; + + return ( + + + {t("SessionLifetimeHelper")} + + + + + {type && ( + <> + + {t("Lifetime")} + + + + )} + + + + ); }; -export default SessionLifetime; +export default inject(({ auth }) => { + const { sessionLifetime, setSessionLifetimeSettings } = auth.settingsStore; + + return { + sessionLifetime, + setSessionLifetimeSettings, + }; +})( + withTranslation(["Settings", "Common"])(withRouter(observer(SessionLifetime))) +); From b0a64cbac77ecc562f9af1597a786f8829b4c97f Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Fri, 8 Apr 2022 16:54:26 +0300 Subject: [PATCH 19/64] Web: Client: Settings: fix after merge --- .../security/access-portal/ipSecurity.js | 19 ++++++++++++++----- .../src/store/SettingsSetupStore.js | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js index a4bddcff38..76e6a7d6d3 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js @@ -8,10 +8,10 @@ import RadioButtonGroup from "@appserver/components/radio-button-group"; import toastr from "@appserver/components/toast/toastr"; import { LearnMoreWrapper } from "../StyledSecurity"; import UserFields from "../sub-components/user-fields"; -import Buttons from "../sub-components/buttons"; import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; import isEqual from "lodash/isEqual"; +import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; const MainContainer = styled.div` width: 100%; @@ -31,6 +31,10 @@ const MainContainer = styled.div` .warning-text { margin-bottom: 9px; } + + .warning-helper { + margin-bottom: 24px; + } `; const IpSecurity = (props) => { @@ -196,13 +200,18 @@ const IpSecurity = (props) => { > {t("Common:Warning")}! - {t("IPSecurityWarningHelper")} + {t("IPSecurityWarningHelper")} - ); diff --git a/web/ASC.Web.Client/src/store/SettingsSetupStore.js b/web/ASC.Web.Client/src/store/SettingsSetupStore.js index 7ea219dfec..4355b7d4dd 100644 --- a/web/ASC.Web.Client/src/store/SettingsSetupStore.js +++ b/web/ASC.Web.Client/src/store/SettingsSetupStore.js @@ -62,6 +62,7 @@ class SettingsSetupStore { if (authStore.isAuthenticated) { await authStore.settingsStore.getPortalPasswordSettings(); await authStore.tfaStore.getTfaType(); + await authStore.settingsStore.getIpRestrictions(); } }; From b33fe33f1809da89ce320604a1266e5a8bca0aa3 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Mon, 11 Apr 2022 12:15:47 +0300 Subject: [PATCH 20/64] Web: Client: Settings: fix show warning --- .../security/access-portal/ipSecurity.js | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js index 76e6a7d6d3..53b6314819 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js @@ -32,8 +32,8 @@ const MainContainer = styled.div` margin-bottom: 9px; } - .warning-helper { - margin-bottom: 24px; + .save-cancel-buttons { + margin-top: 24px; } `; @@ -192,15 +192,19 @@ const IpSecurity = (props) => { /> )} - - {t("Common:Warning")}! - - {t("IPSecurityWarningHelper")} + {enable && ( + <> + + {t("Common:Warning")}! + + {t("IPSecurityWarningHelper")} + + )} Date: Mon, 11 Apr 2022 13:27:37 +0300 Subject: [PATCH 21/64] Web: Client: Settings: add try/catch --- .../security/access-portal/ipSecurity.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js index 53b6314819..b59567aaa5 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js @@ -129,21 +129,25 @@ const IpSecurity = (props) => { setIps([...ips, ""]); }; - const onSaveClick = () => { + const onSaveClick = async () => { const valid = ips.map((ip) => regexp.test(ip)); if (valid.includes(false)) { return; } - setIpRestrictions(ips); - setIpRestrictionsEnable(enable); + try { + await setIpRestrictions(ips); + await setIpRestrictionsEnable(enable); - saveToSessionStorage("defaultIPSettings", { - enable: enable, - ips: ips, - }); - setShowReminder(false); - toastr.success(t("SuccessfullySaveSettingsMessage")); + saveToSessionStorage("defaultIPSettings", { + enable: enable, + ips: ips, + }); + setShowReminder(false); + toastr.success(t("SuccessfullySaveSettingsMessage")); + } catch (error) { + toastr.error(error); + } }; const onCancelClick = () => { From 5dd5e22ba5480d2a27560379d480b7aa5caa062d Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Mon, 11 Apr 2022 17:05:55 +0300 Subject: [PATCH 22/64] Web: Common: fix ipRestrictions --- packages/asc-web-common/api/settings/index.js | 7 +++++++ packages/asc-web-common/store/SettingsStore.js | 15 +++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/asc-web-common/api/settings/index.js b/packages/asc-web-common/api/settings/index.js index a893900d9c..e9ffee5388 100644 --- a/packages/asc-web-common/api/settings/index.js +++ b/packages/asc-web-common/api/settings/index.js @@ -69,6 +69,13 @@ export function setIpRestrictions(data) { }); } +export function getIpRestrictionsEnable() { + return request({ + method: "get", + url: "/settings/iprestrictions/settings", + }); +} + export function setIpRestrictionsEnable(data) { return request({ method: "put", diff --git a/packages/asc-web-common/store/SettingsStore.js b/packages/asc-web-common/store/SettingsStore.js index b490649645..889f15c60c 100644 --- a/packages/asc-web-common/store/SettingsStore.js +++ b/packages/asc-web-common/store/SettingsStore.js @@ -454,8 +454,8 @@ class SettingsStore { getIpRestrictions = async () => { const res = await api.settings.getIpRestrictions(); - if (res.length === 0) this.ipRestrictionEnabled = false; - else this.ipRestrictionEnabled = true; + this.ipRestrictions = res?.map((el) => el.ip); + console.log(this.ipRestrictions); }; setIpRestrictions = async (ips) => { @@ -463,8 +463,12 @@ class SettingsStore { ips: ips, }; const res = await api.settings.setIpRestrictions(data); - console.log("setIpRestrictions", res); - this.ipRestrictions = ips; + this.ipRestrictions = res; + }; + + getIpRestrictionsEnable = async () => { + const res = await api.settings.getIpRestrictionsEnable(); + this.ipRestrictionEnable = res.enable; }; setIpRestrictionsEnable = async (enable) => { @@ -472,8 +476,7 @@ class SettingsStore { enable: enable, }; const res = await api.settings.setIpRestrictionsEnable(data); - console.log("setIpRestrictionsEnable", res); - this.ipRestrictionEnabled = enable; + this.ipRestrictionEnable = res.enable; }; } From 44c2a267d424d4114004cf71f82987500da25e66 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Mon, 11 Apr 2022 17:07:05 +0300 Subject: [PATCH 23/64] Web: Client: Settings: fix get ip restriction enable --- .../categories/security/access-portal/ipSecurity.js | 10 +++++----- web/ASC.Web.Client/src/store/SettingsSetupStore.js | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js index b59567aaa5..69249fa1df 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js @@ -41,7 +41,7 @@ const IpSecurity = (props) => { const { t, history, - ipRestrictionEnabled, + ipRestrictionEnable, setIpRestrictionsEnable, ipRestrictions, setIpRestrictions, @@ -62,7 +62,7 @@ const IpSecurity = (props) => { saveToSessionStorage("defaultIPSettings", defaultSettings); } else { const defaultData = { - enable: ipRestrictionEnabled, + enable: ipRestrictionEnable, ips: ipRestrictions, }; saveToSessionStorage("defaultIPSettings", defaultData); @@ -72,7 +72,7 @@ const IpSecurity = (props) => { setEnable(currentSettings.enable); setIps(currentSettings.ips); } else { - setEnable(ipRestrictionEnabled); + setEnable(ipRestrictionEnable); setIps(ipRestrictions); } @@ -227,14 +227,14 @@ const IpSecurity = (props) => { export default inject(({ auth }) => { const { - ipRestrictionEnabled, + ipRestrictionEnable, setIpRestrictionsEnable, ipRestrictions, setIpRestrictions, } = auth.settingsStore; return { - ipRestrictionEnabled, + ipRestrictionEnable, setIpRestrictionsEnable, ipRestrictions, setIpRestrictions, diff --git a/web/ASC.Web.Client/src/store/SettingsSetupStore.js b/web/ASC.Web.Client/src/store/SettingsSetupStore.js index 4355b7d4dd..10e1be34c6 100644 --- a/web/ASC.Web.Client/src/store/SettingsSetupStore.js +++ b/web/ASC.Web.Client/src/store/SettingsSetupStore.js @@ -62,6 +62,7 @@ class SettingsSetupStore { if (authStore.isAuthenticated) { await authStore.settingsStore.getPortalPasswordSettings(); await authStore.tfaStore.getTfaType(); + await authStore.settingsStore.getIpRestrictionsEnable(); await authStore.settingsStore.getIpRestrictions(); } }; From ce7ac083cae9dbff8605e7ab7c82789563c07e2f Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 10:41:00 +0300 Subject: [PATCH 24/64] Web: Client: Settings: fix ip regex --- .../Settings/categories/security/access-portal/ipSecurity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js index 69249fa1df..ba1f9fb881 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js @@ -47,7 +47,7 @@ const IpSecurity = (props) => { setIpRestrictions, } = props; - const regexp = /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))|((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])/; //check ip valid + const regexp = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|$)){4}$/; //check ip valid const [enable, setEnable] = useState(false); const [ips, setIps] = useState(); From 59e0e53d195cccc5c0fde7f4362941f8b9d33317 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 11:30:43 +0300 Subject: [PATCH 25/64] Web: Client: Settings: use SaveCancelButtons --- .../security/access-portal/adminMessage.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index b504a94320..a9cb058969 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -8,10 +8,10 @@ import Text from "@appserver/components/text"; import Link from "@appserver/components/link"; import toastr from "@appserver/components/toast/toastr"; import { getLanguage } from "@appserver/common/utils"; -import Buttons from "../sub-components/buttons"; import { LearnMoreWrapper } from "../StyledSecurity"; import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; +import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; const MainContainer = styled.div` width: 100%; @@ -19,6 +19,10 @@ const MainContainer = styled.div` .page-subtitle { margin-bottom: 10px; } + + .box { + margin-bottom: 24px; + } `; const AdminMessage = (props) => { @@ -133,11 +137,16 @@ const AdminMessage = (props) => { onClick={onSelectType} /> - ); From 523c79a3ec3d92e74459bd7065398bf6853b1050 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 11:33:35 +0300 Subject: [PATCH 26/64] Web: Client: Settings: use SaveCancelButtons --- .../security/access-portal/sessionLifetime.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js index c012fa1140..64e23750f0 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js @@ -7,10 +7,10 @@ import RadioButtonGroup from "@appserver/components/radio-button-group"; import Text from "@appserver/components/text"; import TextInput from "@appserver/components/text-input"; import toastr from "@appserver/components/toast/toastr"; -import Buttons from "../sub-components/buttons"; import { LearnMoreWrapper } from "../StyledSecurity"; import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; +import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; const MainContainer = styled.div` width: 100%; @@ -19,6 +19,10 @@ const MainContainer = styled.div` margin-top: 16px; margin-bottom: 8px; } + + .save-cancel-buttons { + margin-top: 24px; + } `; const SessionLifetime = (props) => { @@ -79,11 +83,16 @@ const SessionLifetime = (props) => { )} - ); From 3115ce4aec2b7559de7e019ea41aea8fe25131cd Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 11:35:32 +0300 Subject: [PATCH 27/64] Web: Client: Settings: getSessionLifetime --- web/ASC.Web.Client/src/store/SettingsSetupStore.js | 1 + 1 file changed, 1 insertion(+) diff --git a/web/ASC.Web.Client/src/store/SettingsSetupStore.js b/web/ASC.Web.Client/src/store/SettingsSetupStore.js index 15de418028..b58dcd3e54 100644 --- a/web/ASC.Web.Client/src/store/SettingsSetupStore.js +++ b/web/ASC.Web.Client/src/store/SettingsSetupStore.js @@ -64,6 +64,7 @@ class SettingsSetupStore { await authStore.tfaStore.getTfaType(); await authStore.settingsStore.getIpRestrictionsEnable(); await authStore.settingsStore.getIpRestrictions(); + await authStore.settingsStore.getSessionLifetime(); } }; From c02b2313c4e3838dd9b00bf7b13aa733d6b54265 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 13:36:40 +0300 Subject: [PATCH 28/64] Web: Common: fix api request --- packages/asc-web-common/store/SettingsStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/asc-web-common/store/SettingsStore.js b/packages/asc-web-common/store/SettingsStore.js index 5a83ecdf84..de831faf56 100644 --- a/packages/asc-web-common/store/SettingsStore.js +++ b/packages/asc-web-common/store/SettingsStore.js @@ -486,7 +486,7 @@ class SettingsStore { }; getSessionLifetime = async () => { - const res = await api.settings.getSessionLifetime(); + const res = await api.settings.getCookieSettings(); this.sessionLifetime = res; }; From d13180982d5b60ef528ed460918c98f08815533b Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 13:36:55 +0300 Subject: [PATCH 29/64] Web: Client: Settings: add logic --- .../security/access-portal/sessionLifetime.js | 88 ++++++++++++++++++- 1 file changed, 84 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js index 64e23750f0..ec2d3e096e 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js @@ -26,10 +26,71 @@ const MainContainer = styled.div` `; const SessionLifetime = (props) => { - const { t } = props; + const { t, history, lifetime, setSessionLifetimeSettings } = props; const [type, setType] = useState(false); const [sessionLifetime, setSessionLifetime] = useState("0"); const [showReminder, setShowReminder] = useState(false); + const [isLoading, setIsLoading] = useState(false); + + const getSettings = () => { + const currentSettings = getFromSessionStorage( + "currentSessionLifetimeSettings" + ); + const defaultSettings = getFromSessionStorage( + "defaultSessionLifetimeSettings" + ); + + if (defaultSettings) { + saveToSessionStorage("defaultSessionLifetimeSettings", defaultSettings); + } else { + saveToSessionStorage("defaultSessionLifetimeSettings", { + lifetime: lifetime.toString(), + type: lifetime > 0 ? true : false, + }); + } + + if (currentSettings) { + setType(currentSettings.type); + setSessionLifetime(currentSettings.lifetime); + } else { + setType(lifetime > 0 ? true : false); + setSessionLifetime(lifetime.toString()); + } + setIsLoading(true); + }; + + useEffect(() => { + checkWidth(); + getSettings(); + window.addEventListener("resize", checkWidth); + return () => window.removeEventListener("resize", checkWidth); + }, [isLoading]); + + useEffect(() => { + if (!isLoading) return; + + const defaultSettings = getFromSessionStorage( + "defaultSessionLifetimeSettings" + ); + const newSettings = { + lifetime: sessionLifetime, + type: type, + }; + + saveToSessionStorage("currentSessionLifetimeSettings", newSettings); + + if (defaultSettings.type === newSettings.type) { + setShowReminder(false); + } else { + setShowReminder(true); + } + }, [type, sessionLifetime]); + + const checkWidth = () => { + window.innerWidth > size.smallTablet && + history.location.pathname.includes("lifetime") && + history.push("/settings/security/access-portal"); + }; const onSelectType = (e) => { setType(e.target.value === "enable" ? true : false); @@ -39,9 +100,28 @@ const SessionLifetime = (props) => { setSessionLifetime(e.target.value); }; - const onSaveClick = () => {}; + const onSaveClick = async () => { + try { + setSessionLifetimeSettings(sessionLifetime); + toastr.success(t("SuccessfullySaveSettingsMessage")); + saveToSessionStorage("defaultSessionLifetimeSettings", { + lifetime: lifetime, + type: type, + }); + setShowReminder(false); + } catch (error) { + toastr.error(error); + } + }; - const onCancelClick = () => {}; + const onCancelClick = () => { + const defaultSettings = getFromSessionStorage( + "defaultSessionLifetimeSettings" + ); + setType(defaultSettings.type); + setSessionLifetime(defaultSettings.lifetime); + setShowReminder(false); + }; return ( @@ -102,7 +182,7 @@ export default inject(({ auth }) => { const { sessionLifetime, setSessionLifetimeSettings } = auth.settingsStore; return { - sessionLifetime, + lifetime: sessionLifetime, setSessionLifetimeSettings, }; })( From ea6f80987f43ff9b4be2ae48bc8efd9abd2744a7 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 14:15:13 +0300 Subject: [PATCH 30/64] Web: Client: NavMenu: fix style --- .../src/components/NavMenu/sub-components/header-unauth.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js b/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js index 2a8a54f5cd..21bc01d26e 100644 --- a/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js +++ b/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js @@ -13,10 +13,9 @@ const Header = styled.header` align-items: left; background-color: ${(props) => props.theme.header.backgroundColor}; display: flex; - width: calc(100vw - 64px); + width: 100vw; height: 48px; - justify-content: left; - padding: 0 32px; + justify-content: center; .header-items-wrapper { width: 960px; @@ -25,7 +24,7 @@ const Header = styled.header` width: 475px; } @media (max-width: 375px) { - width: 311px; + padding: 0 16px; } } From daca10d9d6aa2beae7d2223b6f114c3c082095ae Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 14:20:31 +0300 Subject: [PATCH 31/64] Web: Components: Themes: add recoveryColor --- packages/asc-web-components/themes/base.js | 2 +- packages/asc-web-components/themes/dark.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/asc-web-components/themes/base.js b/packages/asc-web-components/themes/base.js index b64430d563..5d5183378c 100644 --- a/packages/asc-web-components/themes/base.js +++ b/packages/asc-web-components/themes/base.js @@ -1923,7 +1923,7 @@ const Base = { header: { backgroundColor: "#0F4071", - + recoveryColor: "#27537F", linkColor: "#7a95b0", productColor: white, }, diff --git a/packages/asc-web-components/themes/dark.js b/packages/asc-web-components/themes/dark.js index 7da6c1096f..297b1ace2a 100644 --- a/packages/asc-web-components/themes/dark.js +++ b/packages/asc-web-components/themes/dark.js @@ -1924,7 +1924,7 @@ const Dark = { header: { backgroundColor: "#1f1f1f ", - + recoveryColor: "#4C4C4C", linkColor: "#606060", productColor: "#eeeeee", }, From a7b507bc0fd1ab3ff4c50499a16b0b0047b5de82 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 14:21:03 +0300 Subject: [PATCH 32/64] Web: Client: RecoverAccess: use themes --- .../NavMenu/sub-components/recover-access-container.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/ASC.Web.Client/src/components/NavMenu/sub-components/recover-access-container.js b/web/ASC.Web.Client/src/components/NavMenu/sub-components/recover-access-container.js index 9e1e10bbfb..fa31772e42 100644 --- a/web/ASC.Web.Client/src/components/NavMenu/sub-components/recover-access-container.js +++ b/web/ASC.Web.Client/src/components/NavMenu/sub-components/recover-access-container.js @@ -9,6 +9,7 @@ import UnionIcon from "../svg/union.react.svg"; import RecoverAccessModalDialog from "./recover-access-modal-dialog"; import { sendRecoverRequest } from "@appserver/common/api/settings/index"; import commonIconsStyles from "@appserver/components/utils/common-icons-style"; +import { Base } from "@appserver/components/themes"; const StyledUnionIcon = styled(UnionIcon)` ${commonIconsStyles} @@ -16,6 +17,7 @@ const StyledUnionIcon = styled(UnionIcon)` const RecoverContainer = styled(Box)` cursor: pointer; + background-color: ${(props) => props.theme.header.recoveryColor}; .recover-icon { @media (max-width: 450px) { @@ -29,6 +31,8 @@ const RecoverContainer = styled(Box)` } `; +RecoverContainer.defaultProps = { theme: Base }; + const RecoverAccess = ({ t }) => { const [visible, setVisible] = useState(false); const [loading, setLoading] = useState(false); @@ -88,7 +92,6 @@ const RecoverAccess = ({ t }) => { alignItems="center" > Date: Tue, 12 Apr 2022 14:21:59 +0300 Subject: [PATCH 33/64] Web: Client: NavMenu: fix --- .../src/components/NavMenu/sub-components/header-unauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js b/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js index 21bc01d26e..46c03bb2df 100644 --- a/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js +++ b/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js @@ -109,7 +109,7 @@ export default inject(({ auth }) => { const { enableAdmMess, wizardToken } = settingsStore; return { enableAdmMess, - wizardToken: wizardToken || "/", + wizardToken, isAuthenticated, isLoaded, }; From a9833a0cbc54ce1032fcedfce74bdbf1d7d20337 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 20:44:32 +0300 Subject: [PATCH 34/64] Web: Client: Settings: init settings --- .../categories/security/access-portal/ipSecurity.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js index ba1f9fb881..ce73991707 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js @@ -45,6 +45,7 @@ const IpSecurity = (props) => { setIpRestrictionsEnable, ipRestrictions, setIpRestrictions, + initSettings, } = props; const regexp = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|$)){4}$/; //check ip valid @@ -80,6 +81,7 @@ const IpSecurity = (props) => { }; useEffect(() => { + initSettings(); checkWidth(); getSettings(); window.addEventListener("resize", checkWidth); @@ -225,7 +227,7 @@ const IpSecurity = (props) => { ); }; -export default inject(({ auth }) => { +export default inject(({ auth, setup }) => { const { ipRestrictionEnable, setIpRestrictionsEnable, @@ -233,10 +235,13 @@ export default inject(({ auth }) => { setIpRestrictions, } = auth.settingsStore; + const { initSettings } = setup; + return { ipRestrictionEnable, setIpRestrictionsEnable, ipRestrictions, setIpRestrictions, + initSettings, }; })(withTranslation(["Settings", "Common"])(withRouter(observer(IpSecurity)))); From 4b194e544117bf96330463367281578fe70a7417 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 20:50:58 +0300 Subject: [PATCH 35/64] Web: Client: Settings: fix user field id --- .../categories/security/sub-components/user-fields.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/user-fields.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/user-fields.js index fceec4de6f..3a97f30047 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/user-fields.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/user-fields.js @@ -95,9 +95,9 @@ const UserFields = (props) => { const error = !regexp.test(input); return ( - + onChangeInput(e, index)} From 270731b8eeba84562eeca9f68ea8d913a945f37e Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 12 Apr 2022 20:56:53 +0300 Subject: [PATCH 36/64] Web" Client: Tests: fix id --- web/ASC.Web.Client/tests/action_tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/ASC.Web.Client/tests/action_tests.js b/web/ASC.Web.Client/tests/action_tests.js index 9c9433f7e4..656ef678c8 100644 --- a/web/ASC.Web.Client/tests/action_tests.js +++ b/web/ASC.Web.Client/tests/action_tests.js @@ -820,7 +820,7 @@ Scenario("Trusted mail settings change test success", async ({ I }) => { I.click("Add trusted domain"); I.see({ react: "TextInput" }); - I.fillField("#domain-input-0", "test.com"); + I.fillField("#user-input-0", "test.com"); I.click("Save"); @@ -853,7 +853,7 @@ Scenario("Trusted mail settings change test error", async ({ I }) => { I.click("Add trusted domain"); I.see({ react: "TextInput" }); - I.fillField("#domain-input-0", "test"); + I.fillField("#user-input-0", "test"); I.click("Save"); From 9e611da373cfd906e0e4eae2eaec874ceadfa402 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 14 Apr 2022 15:22:28 +0300 Subject: [PATCH 37/64] Web: Client: Settings: fix --- .../security/access-portal/ipSecurity.js | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js index ce73991707..7a9fcdafd7 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js @@ -46,6 +46,7 @@ const IpSecurity = (props) => { ipRestrictions, setIpRestrictions, initSettings, + isInit, } = props; const regexp = /^(?!0)(?!.*\.$)((1?\d?\d|25[0-5]|2[0-4]\d)(\.|$)){4}$/; //check ip valid @@ -54,20 +55,15 @@ const IpSecurity = (props) => { const [ips, setIps] = useState(); const [showReminder, setShowReminder] = useState(false); const [isLoading, setIsLoading] = useState(false); + const [isSaving, setIsSaving] = useState(false); const getSettings = () => { const currentSettings = getFromSessionStorage("currentIPSettings"); - const defaultSettings = getFromSessionStorage("defaultIPSettings"); - - if (defaultSettings) { - saveToSessionStorage("defaultIPSettings", defaultSettings); - } else { - const defaultData = { - enable: ipRestrictionEnable, - ips: ipRestrictions, - }; - saveToSessionStorage("defaultIPSettings", defaultData); - } + const defaultData = { + enable: ipRestrictionEnable, + ips: ipRestrictions, + }; + saveToSessionStorage("defaultIPSettings", defaultData); if (currentSettings) { setEnable(currentSettings.enable); @@ -76,16 +72,21 @@ const IpSecurity = (props) => { setEnable(ipRestrictionEnable); setIps(ipRestrictions); } - - setIsLoading(true); }; useEffect(() => { - initSettings(); checkWidth(); - getSettings(); window.addEventListener("resize", checkWidth); + + if (!isInit) initSettings().then(() => setIsLoading(true)); + else setIsLoading(true); + return () => window.removeEventListener("resize", checkWidth); + }, []); + + useEffect(() => { + if (!isInit) return; + getSettings(); }, [isLoading]); useEffect(() => { @@ -132,8 +133,10 @@ const IpSecurity = (props) => { }; const onSaveClick = async () => { + setIsSaving(true); const valid = ips.map((ip) => regexp.test(ip)); if (valid.includes(false)) { + setIsSaving(false); return; } @@ -150,6 +153,8 @@ const IpSecurity = (props) => { } catch (error) { toastr.error(error); } + + setIsSaving(false); }; const onCancelClick = () => { @@ -222,6 +227,7 @@ const IpSecurity = (props) => { cancelButtonLabel={t("Common:CancelButton")} displaySettings={true} hasScroll={false} + isSaving={isSaving} /> ); @@ -235,7 +241,7 @@ export default inject(({ auth, setup }) => { setIpRestrictions, } = auth.settingsStore; - const { initSettings } = setup; + const { initSettings, isInit } = setup; return { ipRestrictionEnable, @@ -243,5 +249,6 @@ export default inject(({ auth, setup }) => { ipRestrictions, setIpRestrictions, initSettings, + isInit, }; })(withTranslation(["Settings", "Common"])(withRouter(observer(IpSecurity)))); From 349c3cae0ec81aeac4a8051530cbc6da36745a77 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 1 Jun 2022 13:29:23 +0300 Subject: [PATCH 38/64] Web: Client: Settings: add support ip range --- .../security/sub-components/user-fields.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/user-fields.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/user-fields.js index 3a97f30047..1d59bf877c 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/user-fields.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/user-fields.js @@ -92,7 +92,19 @@ const UserFields = (props) => {
{inputs ? ( inputs.map((input, index) => { - const error = !regexp.test(input); + let newInput1; + let newInput2; + + if (input.includes("-")) { + newInput1 = input.split("-")[0]; + newInput2 = input.split("-")[1]; + } + + const error = newInput2 + ? input.split("-").length - 1 > 1 || + !regexp.test(newInput1) || + !regexp.test(newInput2) + : !regexp.test(input); return ( From d7d21f765ec792cdf8a2ddd0497d44a9afb23b76 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 1 Jun 2022 13:47:42 +0300 Subject: [PATCH 39/64] Web: Client: Settings: fix init settings --- .../security/access-portal/adminMessage.js | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index a9cb058969..9fe519c137 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -26,7 +26,14 @@ const MainContainer = styled.div` `; const AdminMessage = (props) => { - const { t, history, enableAdmMess, setMessageSettings } = props; + const { + t, + history, + enableAdmMess, + setMessageSettings, + initSettings, + isInit, + } = props; const [type, setType] = useState(false); const [showReminder, setShowReminder] = useState(false); const [isLoading, setIsLoading] = useState(false); @@ -55,9 +62,17 @@ const AdminMessage = (props) => { useEffect(() => { checkWidth(); - getSettings(); + + if (!isInit) initSettings().then(() => setIsLoading(true)); + else setIsLoading(true); + window.addEventListener("resize", checkWidth); return () => window.removeEventListener("resize", checkWidth); + }, []); + + useEffect(() => { + if (!isInit) return; + getSettings(); }, [isLoading]); useEffect(() => { @@ -152,11 +167,14 @@ const AdminMessage = (props) => { ); }; -export default inject(({ auth }) => { +export default inject(({ auth, setup }) => { const { enableAdmMess, setMessageSettings } = auth.settingsStore; + const { initSettings, isInit } = setup; return { enableAdmMess, setMessageSettings, + initSettings, + isInit, }; })(withTranslation(["Settings", "Common"])(withRouter(observer(AdminMessage)))); From 98e318ee11071ea36f3a5a008173a10bd4639556 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 1 Jun 2022 14:35:36 +0300 Subject: [PATCH 40/64] Web: Client: Settings: fix init settings --- .../security/access-portal/sessionLifetime.js | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js index ec2d3e096e..f4feed54b1 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js @@ -26,7 +26,14 @@ const MainContainer = styled.div` `; const SessionLifetime = (props) => { - const { t, history, lifetime, setSessionLifetimeSettings } = props; + const { + t, + history, + lifetime, + setSessionLifetimeSettings, + initSettings, + isInit, + } = props; const [type, setType] = useState(false); const [sessionLifetime, setSessionLifetime] = useState("0"); const [showReminder, setShowReminder] = useState(false); @@ -61,9 +68,17 @@ const SessionLifetime = (props) => { useEffect(() => { checkWidth(); - getSettings(); + + if (!isInit) initSettings().then(() => setIsLoading(true)); + else setIsLoading(true); + window.addEventListener("resize", checkWidth); return () => window.removeEventListener("resize", checkWidth); + }, []); + + useEffect(() => { + if (!isInit) return; + getSettings(); }, [isLoading]); useEffect(() => { @@ -178,12 +193,15 @@ const SessionLifetime = (props) => { ); }; -export default inject(({ auth }) => { +export default inject(({ auth, setup }) => { const { sessionLifetime, setSessionLifetimeSettings } = auth.settingsStore; + const { initSettings, isInit } = setup; return { lifetime: sessionLifetime, setSessionLifetimeSettings, + initSettings, + isInit, }; })( withTranslation(["Settings", "Common"])(withRouter(observer(SessionLifetime))) From 8c1cfd2ed88e5110121a42b332b4e449f0773ca2 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 1 Jun 2022 14:43:00 +0300 Subject: [PATCH 41/64] Web: Client: Settings: show error --- .../security/access-portal/sessionLifetime.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js index f4feed54b1..b3dac695e3 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js @@ -38,6 +38,7 @@ const SessionLifetime = (props) => { const [sessionLifetime, setSessionLifetime] = useState("0"); const [showReminder, setShowReminder] = useState(false); const [isLoading, setIsLoading] = useState(false); + const [error, setError] = useState(false); const getSettings = () => { const currentSettings = getFromSessionStorage( @@ -115,7 +116,16 @@ const SessionLifetime = (props) => { setSessionLifetime(e.target.value); }; + const onBlurInput = () => { + !sessionLifetime ? setError(true) : setError(false); + }; + + const onFocusInput = () => { + setError(false); + }; + const onSaveClick = async () => { + if (error) return; try { setSessionLifetimeSettings(sessionLifetime); toastr.success(t("SuccessfullySaveSettingsMessage")); @@ -174,6 +184,9 @@ const SessionLifetime = (props) => { isAutoFocussed={true} value={sessionLifetime} onChange={onChangeInput} + onBlur={onBlurInput} + onFocus={onFocusInput} + hasError={error} /> )} From d0b74d4c30ede8ceae3f34c5ee91cfcbb03ad8f1 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 1 Jun 2022 14:58:34 +0300 Subject: [PATCH 42/64] Web: Client: Settings: fix logic --- .../security/access-portal/sessionLifetime.js | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js index b3dac695e3..86a2a36fb8 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js @@ -11,6 +11,7 @@ import { LearnMoreWrapper } from "../StyledSecurity"; import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; +import isEqual from "lodash/isEqual"; const MainContainer = styled.div` width: 100%; @@ -44,17 +45,18 @@ const SessionLifetime = (props) => { const currentSettings = getFromSessionStorage( "currentSessionLifetimeSettings" ); - const defaultSettings = getFromSessionStorage( - "defaultSessionLifetimeSettings" - ); + const defaultData = { + lifetime: lifetime.toString(), + type: lifetime > 0 ? true : false, + }; + saveToSessionStorage("defaultSessionLifetimeSettings", defaultData); - if (defaultSettings) { - saveToSessionStorage("defaultSessionLifetimeSettings", defaultSettings); + if (currentSettings) { + setSessionLifetime(currentSettings.lifetime); + setType(currentSettings.type); } else { - saveToSessionStorage("defaultSessionLifetimeSettings", { - lifetime: lifetime.toString(), - type: lifetime > 0 ? true : false, - }); + setSessionLifetime(lifetime.toString()); + setType(lifetime > 0 ? true : false); } if (currentSettings) { @@ -95,7 +97,7 @@ const SessionLifetime = (props) => { saveToSessionStorage("currentSessionLifetimeSettings", newSettings); - if (defaultSettings.type === newSettings.type) { + if (isEqual(defaultSettings, newSettings)) { setShowReminder(false); } else { setShowReminder(true); From a1b7a47e45bfdd3e3f94d9d4f6e10612c003c9d4 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 1 Jun 2022 18:25:23 +0300 Subject: [PATCH 43/64] Web: Client: Settings: fix logic --- .../security/access-portal/adminMessage.js | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index 9fe519c137..14f79e2501 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -12,6 +12,7 @@ import { LearnMoreWrapper } from "../StyledSecurity"; import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; +import isEqual from "lodash/isEqual"; const MainContainer = styled.div` width: 100%; @@ -34,7 +35,7 @@ const AdminMessage = (props) => { initSettings, isInit, } = props; - const [type, setType] = useState(false); + const [type, setType] = useState(""); const [showReminder, setShowReminder] = useState(false); const [isLoading, setIsLoading] = useState(false); @@ -42,22 +43,16 @@ const AdminMessage = (props) => { const currentSettings = getFromSessionStorage( "currentAdminMessageSettings" ); - const defaultSettings = getFromSessionStorage( - "defaultAdminMessageSettings" - ); - if (defaultSettings) { - saveToSessionStorage("defaultAdminMessageSettings", defaultSettings); - } else { - saveToSessionStorage("defaultAdminMessageSettings", enableAdmMess); - } + const enable = enableAdmMess ? "enable" : "disabled"; + + saveToSessionStorage("defaultAdminMessageSettings", enable); if (currentSettings) { setType(currentSettings); } else { - setType(enableAdmMess); + setType(enable); } - setIsLoading(true); }; useEffect(() => { @@ -83,7 +78,8 @@ const AdminMessage = (props) => { ); saveToSessionStorage("currentAdminMessageSettings", type); - if (defaultSettings === type) { + if (isEqual(defaultSettings, type)) { + console.log("==="); setShowReminder(false); } else { setShowReminder(true); @@ -97,7 +93,9 @@ const AdminMessage = (props) => { }; const onSelectType = (e) => { - setType(e.target.value === "enable" ? true : false); + if (type !== e.target.value) { + setType(e.target.value); + } }; const onSaveClick = () => { @@ -148,7 +146,7 @@ const AdminMessage = (props) => { value: "enable", }, ]} - selected={type ? "enable" : "disabled"} + selected={type} onClick={onSelectType} /> From 1aa605fb98ef135cfe63ec78ae6cbfc18a2619e5 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 1 Jun 2022 18:27:36 +0300 Subject: [PATCH 44/64] Web: Client: Settings: delete console log --- .../Settings/categories/security/access-portal/adminMessage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index 14f79e2501..309294aaf7 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -79,7 +79,6 @@ const AdminMessage = (props) => { saveToSessionStorage("currentAdminMessageSettings", type); if (isEqual(defaultSettings, type)) { - console.log("==="); setShowReminder(false); } else { setShowReminder(true); From 45742f6f1e240ba3e7222c82b1872510f83cc932 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 7 Jun 2022 14:21:22 +0300 Subject: [PATCH 45/64] Web: Common: SettingsStore: delete console log --- packages/asc-web-common/store/SettingsStore.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/asc-web-common/store/SettingsStore.js b/packages/asc-web-common/store/SettingsStore.js index ad00c8fd57..7900a79c0d 100644 --- a/packages/asc-web-common/store/SettingsStore.js +++ b/packages/asc-web-common/store/SettingsStore.js @@ -481,7 +481,6 @@ class SettingsStore { getIpRestrictions = async () => { const res = await api.settings.getIpRestrictions(); this.ipRestrictions = res?.map((el) => el.ip); - console.log(this.ipRestrictions); }; setIpRestrictions = async (ips) => { From 1472644f04b1067bf351a95809a9272e62d58f7f Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 8 Jun 2022 15:35:22 +0300 Subject: [PATCH 46/64] Web: Client: Settings: add loader --- .../Settings/categories/security/index.js | 4 +- .../sub-components/loaders/security-loader.js | 188 ++++++++++++++++++ 2 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/security-loader.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/index.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/index.js index 81ccced56f..76c5d7de44 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/index.js @@ -9,7 +9,7 @@ import config from "../../../../../../package.json"; import AccessRights from "./access-rights/index.js"; import AccessPortal from "./access-portal/index.js"; -import AppLoader from "@appserver/common/components/AppLoader"; +import SecurityLoader from "./sub-components/loaders/security-loader"; const SecurityWrapper = (props) => { const { t, history, loadBaseInfo } = props; @@ -51,7 +51,7 @@ const SecurityWrapper = (props) => { ); }; - if (!isLoading) return ; + if (!isLoading) return ; return ( { + return ( + + +
+ + + + +
+ + +
+ + +
+ + +
+
+ + + +
+ +
+
+
+ +
+ + + +
+ +
+
+
+ +
+ + + +
+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+ ); +}; + +export default SecurityLoader; From 83fc657f4b692a46ecea56d30f05c4e8b21e356d Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 8 Jun 2022 16:13:44 +0300 Subject: [PATCH 47/64] Web: Client: Settings: add mobile security loader --- .../loaders/mobile-security-loader.js | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/mobile-security-loader.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/mobile-security-loader.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/mobile-security-loader.js new file mode 100644 index 0000000000..40a51e2cc4 --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/mobile-security-loader.js @@ -0,0 +1,59 @@ +import React from "react"; +import styled from "styled-components"; +import Loaders from "@appserver/common/components/Loaders"; + +const StyledLoader = styled.div` + .header { + width: 273px; + margin-bottom: 18px; + } + + .submenu { + display: flex; + gap: 20px; + margin-bottom: 30px; + } + + .category { + display: flex; + flex-direction: column; + gap: 8px; + margin-bottom: 30px; + } +`; + +const MobileSecurityLoader = () => { + return ( + + +
+ + + + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ ); +}; + +export default MobileSecurityLoader; From 749feab8e81929dfc2d09e6056482112868069d5 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 8 Jun 2022 16:14:03 +0300 Subject: [PATCH 48/64] Web: Client: Settings: add access loader --- .../Settings/categories/security/index.js | 22 ++++- .../sub-components/loaders/access-loader.js | 86 +++++++++++++++++++ 2 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/access-loader.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/index.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/index.js index 76c5d7de44..08c2b94940 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/index.js @@ -10,6 +10,10 @@ import config from "../../../../../../package.json"; import AccessRights from "./access-rights/index.js"; import AccessPortal from "./access-portal/index.js"; import SecurityLoader from "./sub-components/loaders/security-loader"; +import MobileSecurityLoader from "./sub-components/loaders/mobile-security-loader"; +import AccessLoader from "./sub-components/loaders/access-loader"; + +import { isMobile } from "react-device-detect"; const SecurityWrapper = (props) => { const { t, history, loadBaseInfo } = props; @@ -31,13 +35,14 @@ const SecurityWrapper = (props) => { const load = async () => { await loadBaseInfo(); - const path = location.pathname; - const currentTab = data.findIndex((item) => path.includes(item.id)); - if (currentTab !== -1) setCurrentTab(currentTab); setIsLoading(true); }; useEffect(() => { + const path = location.pathname; + const currentTab = data.findIndex((item) => path.includes(item.id)); + if (currentTab !== -1) setCurrentTab(currentTab); + load(); }, []); @@ -51,7 +56,16 @@ const SecurityWrapper = (props) => { ); }; - if (!isLoading) return ; + if (!isLoading) + return currentTab === 0 ? ( + isMobile ? ( + + ) : ( + + ) + ) : ( + + ); return ( { + return ( + + +
+ + + + +
+
+ + +
+
+ + + +
+
+ ); +}; + +export default AccessLoader; From d5c8ab19dd3ee297d6c3e9c4b4bcb304b74860f6 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 8 Jun 2022 17:23:28 +0300 Subject: [PATCH 49/64] Web: Client: Settings: add password strength loader --- .../access-portal/passwordStrength.js | 6 ++ .../sub-components/loaders/password-loader.js | 70 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/password-loader.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/passwordStrength.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/passwordStrength.js index 58780a757a..d406fe7750 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/passwordStrength.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/passwordStrength.js @@ -15,6 +15,8 @@ import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; import isEqual from "lodash/isEqual"; import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; +import { isMobile } from "react-device-detect"; +import PasswordLoader from "../sub-components/loaders/password-loader"; const MainContainer = styled.div` width: 100%; @@ -177,6 +179,10 @@ const PasswordStrength = (props) => { const lng = getLanguage(localStorage.getItem("language") || "en"); + if (isMobile && !isInit && !isLoading) { + return ; + } + return ( diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/password-loader.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/password-loader.js new file mode 100644 index 0000000000..6cbcf58ce9 --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/password-loader.js @@ -0,0 +1,70 @@ +import React from "react"; +import styled from "styled-components"; +import Loaders from "@appserver/common/components/Loaders"; + +const StyledLoader = styled.div` + padding-right: 8px; + + .header { + width: 273px; + margin-bottom: 16px; + } + + .description { + margin-bottom: 8px; + } + + .link { + margin-bottom: 20px; + } + + .subheader { + margin-bottom: 16px; + } + + .slider { + display: flex; + gap: 16px; + align-items: center; + margin-bottom: 16px; + } + + .checkboxs { + display: flex; + flex-direction: column; + gap: 8px; + width: 50px; + } + + .buttons { + width: calc(100% - 32px); + position: absolute; + bottom: 16px; + } +`; + +const PasswordLoader = () => { + return ( + + + +
+ +
+ +
+ + +
+
+ + + +
+ + +
+ ); +}; + +export default PasswordLoader; From 921d479639cf58490e2dd6c4679bad05b924ec1f Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 8 Jun 2022 17:27:23 +0300 Subject: [PATCH 50/64] Web: Client: Settings: add tfa loader --- .../categories/security/access-portal/tfa.js | 7 +++ .../sub-components/loaders/tfa-loader.js | 55 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/tfa-loader.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/tfa.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/tfa.js index bf59724435..4f39a9b586 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/tfa.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/tfa.js @@ -12,6 +12,8 @@ import { LearnMoreWrapper } from "../StyledSecurity"; import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; +import { isMobile } from "react-device-detect"; +import TfaLoader from "../sub-components/loaders/tfa-loader"; const MainContainer = styled.div` width: 100%; @@ -117,6 +119,11 @@ const TwoFactorAuth = (props) => { }; const lng = getLanguage(localStorage.getItem("language") || "en"); + + if (isMobile && !isInit && !isLoading) { + return ; + } + return ( diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/tfa-loader.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/tfa-loader.js new file mode 100644 index 0000000000..824b6fc0a4 --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/tfa-loader.js @@ -0,0 +1,55 @@ +import React from "react"; +import styled from "styled-components"; +import Loaders from "@appserver/common/components/Loaders"; + +const StyledLoader = styled.div` + padding-right: 8px; + + .header { + width: 273px; + margin-bottom: 16px; + } + + .description { + margin-bottom: 8px; + } + + .link { + margin-bottom: 20px; + } + + .checkboxs { + display: flex; + flex-direction: column; + gap: 8px; + width: 50px; + } + + .buttons { + width: calc(100% - 32px); + position: absolute; + bottom: 16px; + } +`; + +const TfaLoader = () => { + return ( + + + +
+ +
+ +
+ + + +
+ + +
+ ); +}; + +export default TfaLoader; From ff30a5848039d1fec3161bebcce6efcbfbaef77f Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 8 Jun 2022 17:34:59 +0300 Subject: [PATCH 51/64] Web: Client: Settings: add trusted mail loader --- .../security/access-portal/trustedMail.js | 7 ++ .../loaders/trusted-mail-loader.js | 90 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/trusted-mail-loader.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/trustedMail.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/trustedMail.js index 6adca3eaf3..570af6aacc 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/trustedMail.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/trustedMail.js @@ -14,6 +14,8 @@ import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; import isEqual from "lodash/isEqual"; import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; +import { isMobile } from "react-device-detect"; +import TrustedMailLoader from "../sub-components/loaders/trusted-mail-loader"; const MainContainer = styled.div` width: 100%; @@ -151,6 +153,11 @@ const TrustedMail = (props) => { }; const lng = getLanguage(localStorage.getItem("language") || "en"); + + if (isMobile && !isLoading) { + return ; + } + return ( diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/trusted-mail-loader.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/trusted-mail-loader.js new file mode 100644 index 0000000000..6a0ba7a7e3 --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/trusted-mail-loader.js @@ -0,0 +1,90 @@ +import React from "react"; +import styled from "styled-components"; +import Loaders from "@appserver/common/components/Loaders"; + +const StyledLoader = styled.div` + padding-right: 8px; + + .header { + width: 273px; + margin-bottom: 16px; + } + + .description { + margin-bottom: 8px; + } + + .link { + margin-bottom: 20px; + } + + .checkboxs { + display: flex; + flex-direction: column; + gap: 8px; + width: 50px; + margin-bottom: 11px; + } + + .inputs { + display: flex; + flex-direction: column; + gap: 8px; + + .input { + display: flex; + gap: 8px; + align-items: center; + } + + .add { + width: 85px; + margin-top: 16px; + } + } + + .buttons { + width: calc(100% - 32px); + position: absolute; + bottom: 16px; + } +`; + +const TrustedMailLoader = () => { + return ( + + + +
+ +
+ +
+ + + +
+ +
+
+ + +
+
+ + +
+
+ + +
+ + +
+ + +
+ ); +}; + +export default TrustedMailLoader; From 860db2916fe59c4d2233be377c528754863a599f Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 8 Jun 2022 17:41:38 +0300 Subject: [PATCH 52/64] Web: Client: Settings: add ip security loader --- .../security/access-portal/ipSecurity.js | 6 ++ .../loaders/ip-security-loader.js | 66 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/ip-security-loader.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js index 7a9fcdafd7..4317605fc9 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/ipSecurity.js @@ -12,6 +12,8 @@ import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; import isEqual from "lodash/isEqual"; import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; +import { isMobile } from "react-device-detect"; +import IpSecurityLoader from "../sub-components/loaders/ip-security-loader"; const MainContainer = styled.div` width: 100%; @@ -164,6 +166,10 @@ const IpSecurity = (props) => { setShowReminder(false); }; + if (isMobile && !isInit && !isLoading) { + return ; + } + return ( diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/ip-security-loader.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/ip-security-loader.js new file mode 100644 index 0000000000..3fcc158249 --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/ip-security-loader.js @@ -0,0 +1,66 @@ +import React from "react"; +import styled from "styled-components"; +import Loaders from "@appserver/common/components/Loaders"; + +const StyledLoader = styled.div` + padding-right: 8px; + + .header { + width: 273px; + margin-bottom: 16px; + } + + .description { + margin-bottom: 12px; + } + + .checkboxs { + display: flex; + flex-direction: column; + gap: 8px; + width: 50px; + margin-bottom: 15px; + } + + .add-button { + width: 85px; + margin-bottom: 16px; + } + + .block { + display: flex; + flex-direction: column; + gap: 8px; + } + + .buttons { + width: calc(100% - 32px); + position: absolute; + bottom: 16px; + } +`; + +const IpSecurityLoader = () => { + return ( + + + + +
+ + +
+ + + +
+ + +
+ + +
+ ); +}; + +export default IpSecurityLoader; From 6ec27544aacf3cc1aba996372b3013c0a8f96959 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 8 Jun 2022 17:46:17 +0300 Subject: [PATCH 53/64] Web: Client: Settings: add admin message loader --- .../security/access-portal/adminMessage.js | 6 ++ .../sub-components/loaders/admmsg-loader.js | 55 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/admmsg-loader.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index 309294aaf7..b122170e63 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -13,6 +13,8 @@ import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; import isEqual from "lodash/isEqual"; +import { isMobile } from "react-device-detect"; +import AdmMsgLoader from "../sub-components/loaders/admmsg-loader"; const MainContainer = styled.div` width: 100%; @@ -114,6 +116,10 @@ const AdminMessage = (props) => { const lng = getLanguage(localStorage.getItem("language") || "en"); + if (isMobile && !isInit && !isLoading) { + return ; + } + return ( diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/admmsg-loader.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/admmsg-loader.js new file mode 100644 index 0000000000..b6cc12e453 --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/admmsg-loader.js @@ -0,0 +1,55 @@ +import React from "react"; +import styled from "styled-components"; +import Loaders from "@appserver/common/components/Loaders"; + +const StyledLoader = styled.div` + padding-right: 8px; + + .header { + width: 273px; + margin-bottom: 16px; + } + + .description { + margin-bottom: 8px; + } + + .link { + margin-bottom: 20px; + } + + .checkboxs { + display: flex; + flex-direction: column; + gap: 8px; + width: 50px; + margin-bottom: 11px; + } + + .buttons { + width: calc(100% - 32px); + position: absolute; + bottom: 16px; + } +`; + +const AdmMsgLoader = () => { + return ( + + + +
+ +
+ +
+ + +
+ + +
+ ); +}; + +export default AdmMsgLoader; From 59eee29c61889e9ce03fdcdf89ded6a9c39b8e60 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 8 Jun 2022 17:51:26 +0300 Subject: [PATCH 54/64] Web: Client: Settings: add session lifetime loader --- .../security/access-portal/sessionLifetime.js | 6 ++ .../loaders/session-lifetime-loader.js | 59 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/session-lifetime-loader.js diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js index 86a2a36fb8..8ecb8648dd 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/sessionLifetime.js @@ -12,6 +12,8 @@ import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; import SaveCancelButtons from "@appserver/components/save-cancel-buttons"; import isEqual from "lodash/isEqual"; +import { isMobile } from "react-device-detect"; +import SessionLifetimeLoader from "../sub-components/loaders/session-lifetime-loader"; const MainContainer = styled.div` width: 100%; @@ -150,6 +152,10 @@ const SessionLifetime = (props) => { setShowReminder(false); }; + if (isMobile && !isInit && !isLoading) { + return ; + } + return ( diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/session-lifetime-loader.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/session-lifetime-loader.js new file mode 100644 index 0000000000..0c2f0e7378 --- /dev/null +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/sub-components/loaders/session-lifetime-loader.js @@ -0,0 +1,59 @@ +import React from "react"; +import styled from "styled-components"; +import Loaders from "@appserver/common/components/Loaders"; + +const StyledLoader = styled.div` + padding-right: 8px; + + .header { + width: 273px; + margin-bottom: 16px; + } + + .description { + margin-bottom: 12px; + } + + .checkboxs { + display: flex; + flex-direction: column; + gap: 8px; + width: 50px; + margin-bottom: 16px; + } + + .input { + display: flex; + flex-direction: column; + gap: 4px; + } + + .buttons { + width: calc(100% - 32px); + position: absolute; + bottom: 16px; + } +`; + +const SessionLifetimeLoader = () => { + return ( + + + + +
+ + +
+ +
+ + +
+ + +
+ ); +}; + +export default SessionLifetimeLoader; From 1df086f40807841ca6e3d333909b8539e2f6fc85 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 8 Jun 2022 17:58:11 +0300 Subject: [PATCH 55/64] Web: Client: Settings: use help link --- .../categories/security/access-portal/adminMessage.js | 9 ++++----- .../Settings/categories/security/access-portal/index.js | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index b122170e63..a1658f26ba 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -7,7 +7,6 @@ import RadioButtonGroup from "@appserver/components/radio-button-group"; import Text from "@appserver/components/text"; import Link from "@appserver/components/link"; import toastr from "@appserver/components/toast/toastr"; -import { getLanguage } from "@appserver/common/utils"; import { LearnMoreWrapper } from "../StyledSecurity"; import { size } from "@appserver/components/utils/device"; import { saveToSessionStorage, getFromSessionStorage } from "../../../utils"; @@ -36,6 +35,7 @@ const AdminMessage = (props) => { setMessageSettings, initSettings, isInit, + helpLink, } = props; const [type, setType] = useState(""); const [showReminder, setShowReminder] = useState(false); @@ -114,8 +114,6 @@ const AdminMessage = (props) => { setShowReminder(false); }; - const lng = getLanguage(localStorage.getItem("language") || "en"); - if (isMobile && !isInit && !isLoading) { return ; } @@ -128,7 +126,7 @@ const AdminMessage = (props) => { color="#316DAA" target="_blank" isHovered - href={`https://helpcenter.onlyoffice.com/${lng}/administration/configuration.aspx#ChangingSecuritySettings_block`} + href={`${helpLink}/administration/configuration.aspx#ChangingSecuritySettings_block`} > {t("Common:LearnMore")} @@ -171,7 +169,7 @@ const AdminMessage = (props) => { }; export default inject(({ auth, setup }) => { - const { enableAdmMess, setMessageSettings } = auth.settingsStore; + const { enableAdmMess, setMessageSettings, helpLink } = auth.settingsStore; const { initSettings, isInit } = setup; return { @@ -179,5 +177,6 @@ export default inject(({ auth, setup }) => { setMessageSettings, initSettings, isInit, + helpLink, }; })(withTranslation(["Settings", "Common"])(withRouter(observer(AdminMessage)))); diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js index fa86ff8975..647694593c 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/index.js @@ -72,7 +72,7 @@ const AccessPortal = (props) => { t={t} title={t("AdminsMessage")} tooltipTitle={t("AdminsMessageDescription")} - tooltipUrl={`https://helpcenter.onlyoffice.com/${lng}/administration/configuration.aspx#ChangingSecuritySettings_block`} + tooltipUrl={`${helpLink}/administration/configuration.aspx#ChangingSecuritySettings_block`} /> From 6a690fc175a2b493a57482a2dc7b0071407f928c Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Fri, 8 Jul 2022 16:22:08 +0300 Subject: [PATCH 56/64] Web: Client: fix confirmLinkData --- web/ASC.Web.Client/src/helpers/confirmRoute.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/web/ASC.Web.Client/src/helpers/confirmRoute.js b/web/ASC.Web.Client/src/helpers/confirmRoute.js index c16e7054ff..2ae5138ca1 100644 --- a/web/ASC.Web.Client/src/helpers/confirmRoute.js +++ b/web/ASC.Web.Client/src/helpers/confirmRoute.js @@ -43,9 +43,7 @@ class ConfirmRoute extends React.Component { .then((validationResult) => { switch (validationResult) { case ValidationResult.Ok: - const confirmHeader = `type=${confirmLinkData.type}&${search.slice( - 1 - )}`; + const confirmHeader = `${confirmLinkData}&${search.slice(1)}`; const linkData = { ...confirmLinkData, confirmHeader, From f69194b03484ec45d498759ac93d82fd313bad17 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Fri, 8 Jul 2022 16:22:30 +0300 Subject: [PATCH 57/64] Web: Client: TfaActivation: fix error --- .../components/pages/Confirm/sub-components/tfaActivation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/tfaActivation.js b/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/tfaActivation.js index 44e1b012bf..759e65e961 100644 --- a/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/tfaActivation.js +++ b/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/tfaActivation.js @@ -233,7 +233,7 @@ const TfaActivationWrapper = (props) => { setSecretKey(manualEntryKey); setQrCode(qrCodeSetupImageUrl); } catch (e) { - setError(e); + setError(e.error); toastr.error(e); } From 1f3dfb9ccc53ecb43261e202313eb80924fc85ff Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Fri, 8 Jul 2022 16:46:26 +0300 Subject: [PATCH 58/64] Web: Client: AdminMessage: fix save --- .../Settings/categories/security/access-portal/adminMessage.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js index a1658f26ba..328656043f 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/security/access-portal/adminMessage.js @@ -100,7 +100,8 @@ const AdminMessage = (props) => { }; const onSaveClick = () => { - setMessageSettings(type); + const turnOn = type === "enable" ? true : false; + setMessageSettings(turnOn); toastr.success(t("SuccessfullySaveSettingsMessage")); saveToSessionStorage("defaultAdminMessageSettings", type); setShowReminder(false); From b3324ad875d60c304f47708cd5b0e55dc84c4b42 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Mon, 11 Jul 2022 11:28:25 +0300 Subject: [PATCH 59/64] Web: Client: NavMenu: fix namespace --- .../src/components/NavMenu/sub-components/header-unauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js b/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js index 46c03bb2df..f0886bab68 100644 --- a/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js +++ b/web/ASC.Web.Client/src/components/NavMenu/sub-components/header-unauth.js @@ -56,7 +56,7 @@ const HeaderUnAuth = ({ isAuthenticated, isLoaded, }) => { - const { t } = useTranslation(); + const { t } = useTranslation("NavMenu"); return (
From 3cbfa3d952cde2346b4979a88db0f2d188c7239e Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Mon, 11 Jul 2022 13:57:58 +0300 Subject: [PATCH 60/64] Web: Client: TfaAuth: fix layout --- .../pages/Confirm/sub-components/tfaAuth.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/tfaAuth.js b/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/tfaAuth.js index db9df73b4c..a445322e73 100644 --- a/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/tfaAuth.js +++ b/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/tfaAuth.js @@ -11,7 +11,11 @@ import { inject, observer } from "mobx-react"; import Box from "@appserver/components/box"; import toastr from "studio/toastr"; import withLoader from "../withLoader"; -import { mobile, tablet } from "@appserver/components/utils/device"; +import { + hugeMobile, + smallTablet, + tablet, +} from "@appserver/components/utils/device"; const StyledForm = styled(Box)` margin: 63px auto; @@ -24,9 +28,15 @@ const StyledForm = styled(Box)` margin: 120px auto; width: 480px; } - @media ${mobile} { - margin: 72px 16px auto 8px; - width: 311px; + + @media ${smallTablet} { + width: 400px; + } + + @media ${hugeMobile} { + margin: 72px 8px auto 8px; + padding: 16px; + width: 100%; } .app-code-wrapper { From 136a0d45bf8ebc2d9c6fb8207160e9c64ca41436 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Mon, 11 Jul 2022 14:47:57 +0300 Subject: [PATCH 61/64] Web: Client: TfaActivation: fix layout --- .../Confirm/sub-components/tfaActivation.js | 212 +++++++++--------- 1 file changed, 101 insertions(+), 111 deletions(-) diff --git a/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/tfaActivation.js b/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/tfaActivation.js index 759e65e961..99e8f4d237 100644 --- a/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/tfaActivation.js +++ b/web/ASC.Web.Client/src/components/pages/Confirm/sub-components/tfaActivation.js @@ -12,12 +12,11 @@ import Box from "@appserver/components/box"; import withLoader from "../withLoader"; import toastr from "studio/toastr"; import ErrorContainer from "@appserver/common/components/ErrorContainer"; -import { mobile, tablet } from "@appserver/components/utils/device"; +import { hugeMobile, tablet } from "@appserver/components/utils/device"; import Link from "@appserver/components/link"; const StyledForm = styled(Box)` margin: 63px auto auto 216px; - width: 960px; display: flex; flex: 1fr 1fr; gap: 80px; @@ -31,9 +30,9 @@ const StyledForm = styled(Box)` gap: 32px; } - @media ${mobile} { - margin: 72px 16px auto 8px; - width: 311px; + @media ${hugeMobile} { + margin-top: 72px; + width: 100%; flex: 1fr; flex-direction: column; gap: 0px; @@ -45,6 +44,11 @@ const StyledForm = styled(Box)` } } + .set-app-description { + width: 100%; + max-width: 500px; + } + .set-app-title { margin-bottom: 14px; } @@ -62,7 +66,7 @@ const StyledForm = styled(Box)` border-radius: 6px; margin-bottom: 32px; - @media ${mobile} { + @media ${hugeMobile} { display: none; } } @@ -106,113 +110,95 @@ const TfaActivationForm = withLoader((props) => { if (target.code === "Enter" || target.code === "NumpadEnter") onSubmit(); }; - const width = window.innerWidth; - return ( -
- - -
- - - {t("SetAppTitle")} - + + + + {t("SetAppTitle")} + - - The two-factor authentication is enabled to provide additional - portal security. Configure your authenticator application to - continue work on the portal. For example you could use Google - Authenticator for - - Android - - and{" "} - - iOS - {" "} - or Authenticator for{" "} - - Windows Phone - {" "} - . - + + The two-factor authentication is enabled to provide additional portal + security. Configure your authenticator application to continue work on + the portal. For example you could use Google Authenticator for + + Android + + and{" "} + + iOS + {" "} + or Authenticator for{" "} + + Windows Phone + {" "} + . + - - - To connect your apllication scan the QR code or manually enter - your secret key {{ secretKey }} then enter - 6-digit code from your application in the field below. - - - -
-
- -
- QR-code -
- - - { - setCode(e.target.value); - setError(""); - }} - value={code} - hasError={error ? true : false} - onKeyDown={onKeyPress} - /> - - - -
-
-
-
+ + + To connect your apllication scan the QR code or manually enter your + secret key {{ secretKey }} then enter 6-digit code + from your application in the field below. + + + + +
+ QR-code +
+ + + { + setCode(e.target.value); + setError(""); + }} + value={code} + hasError={error ? true : false} + onKeyDown={onKeyPress} + /> + + + +