From d66033938b37bf7033c27011b23b47e68a099001 Mon Sep 17 00:00:00 2001 From: volodymyr Date: Tue, 16 Jul 2024 18:28:29 +0300 Subject: [PATCH 1/2] feature: new PasswordRegExp config adding WIP [WTEL-4702] --- package-lock.json | 8 ++++---- package.json | 2 +- .../users/components/opened-user-general.vue | 12 +++++++++++ .../configuration/api/configuration.js | 4 ++-- .../components/configuration-popup.vue | 20 +++++++++++++++++++ .../utils/configurationValueTypes.js | 2 ++ 6 files changed, 41 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index b7e201a6f..452c01bc2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,7 @@ "vue-router": "^4.2.5", "vue2-dropzone": "^3.6.0", "vuex": "^4.1.0", - "webitel-sdk": "^24.4.7" + "webitel-sdk": "^24.4.13" }, "devDependencies": { "@biomejs/biome": "^1.8.3", @@ -9180,9 +9180,9 @@ } }, "node_modules/webitel-sdk": { - "version": "24.4.7", - "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-24.4.7.tgz", - "integrity": "sha512-VR4yyN2kMgwv22dW2qnXaoDZV7hKdOUn73rg8FqJy5fKd9BmJz63d68USbq58COyWlgdoXFRWsiSWeu+Drm5NQ==", + "version": "24.4.13", + "resolved": "https://registry.npmjs.org/webitel-sdk/-/webitel-sdk-24.4.13.tgz", + "integrity": "sha512-8jMs/gjf3gBvHIkVU4k0/iwUz66T1NFfS0GGG37COPwTSqtYd3Cei8zKcm2HiYFpFZ2fVjKZYfW6BBuEUevJdg==", "dependencies": { "@types/webrtc": "~0.0.41", "deep-copy": "1.4.2", diff --git a/package.json b/package.json index 86e7ba585..2ac17e75f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "vue-router": "^4.2.5", "vue2-dropzone": "^3.6.0", "vuex": "^4.1.0", - "webitel-sdk": "^24.4.7" + "webitel-sdk": "^24.4.13" }, "devDependencies": { "@biomejs/biome": "^1.8.3", diff --git a/src/modules/directory/modules/users/components/opened-user-general.vue b/src/modules/directory/modules/users/components/opened-user-general.vue index 2563d0c1c..fd5a33d97 100644 --- a/src/modules/directory/modules/users/components/opened-user-general.vue +++ b/src/modules/directory/modules/users/components/opened-user-general.vue @@ -55,8 +55,10 @@ diff --git a/src/modules/system/modules/configuration/api/configuration.js b/src/modules/system/modules/configuration/api/configuration.js index 815497a43..ae670a9d3 100644 --- a/src/modules/system/modules/configuration/api/configuration.js +++ b/src/modules/system/modules/configuration/api/configuration.js @@ -14,13 +14,13 @@ import configuration from '../../../../../app/api/openAPIConfig'; const service = new SystemSettingServiceApiFactory(configuration, '', instance); const getList = async (params) => { - const { page, size, search, sort, fields } = applyTransform(params, [ + const { page, size, search, sort, fields, name } = applyTransform(params, [ merge(getDefaultGetParams()), starToSearch('search'), ]); try { - const response = await service.searchSystemSetting(page, size, search, sort, fields); + const response = await service.searchSystemSetting(page, size, search, sort, fields, name); const { items, next } = applyTransform(response.data, [ snakeToCamel(), merge(getDefaultGetListResponse()), diff --git a/src/modules/system/modules/configuration/components/configuration-popup.vue b/src/modules/system/modules/configuration/components/configuration-popup.vue index 56e75f4b3..d69694823 100644 --- a/src/modules/system/modules/configuration/components/configuration-popup.vue +++ b/src/modules/system/modules/configuration/components/configuration-popup.vue @@ -61,6 +61,14 @@ @input="inputHandler" /> + @@ -145,6 +153,14 @@ export default { }; } + const defaultStringConfig = { + itemInstance: { + value: { + required, + }, + }, + }; + switch (this.itemInstance.name) { case EngineSystemSettingName.EnableOmnichannel: return deepmerge(defaults, defaultBooleanConfig); @@ -160,6 +176,10 @@ export default { return deepmerge(defaults, defaultNumberConfig); case EngineSystemSettingName.ExportSettings: return deepmerge(defaults, defaultSelectConfig); + case EngineSystemSettingName.PasswordRegExp: + return deepmerge(defaults, defaultStringConfig); + case EngineSystemSettingName.PasswordValidationText: + return deepmerge(defaults, defaultStringConfig); default: return defaults; } diff --git a/src/modules/system/modules/configuration/utils/configurationValueTypes.js b/src/modules/system/modules/configuration/utils/configurationValueTypes.js index c4b35f3cc..28d40e1e1 100644 --- a/src/modules/system/modules/configuration/utils/configurationValueTypes.js +++ b/src/modules/system/modules/configuration/utils/configurationValueTypes.js @@ -8,6 +8,8 @@ const ConfigurationValueTypes = Object.freeze({ [EngineSystemSettingName.SchemeVersionLimit]: 'number', [EngineSystemSettingName.SearchNumberLength]: 'number', [EngineSystemSettingName.ExportSettings]: 'select', + [EngineSystemSettingName.PasswordRegExp]: 'string', + [EngineSystemSettingName.PasswordValidationText]: 'string', }, ); From 9b7bb7ce2bdc7fc6845ea11d15d6d13b0af03f07 Mon Sep 17 00:00:00 2001 From: volodymyr Date: Thu, 18 Jul 2024 20:41:03 +0300 Subject: [PATCH 2/2] feature: new PasswordRegExp config added, waiting for PasswordValidationText[WTEL-4702] --- src/app/utils/validators.js | 11 ++++ .../users/components/opened-user-general.vue | 12 ---- .../modules/users/components/opened-user.vue | 57 +++++++++++++------ 3 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/app/utils/validators.js b/src/app/utils/validators.js index 4fa65639b..1bab222f2 100644 --- a/src/app/utils/validators.js +++ b/src/app/utils/validators.js @@ -1,3 +1,5 @@ +import { helpers } from '@vuelidate/validators'; + export const macValidator = (value) => { if (typeof value === 'undefined' || value === null || value === '') { return true; @@ -81,3 +83,12 @@ export const regExpValidator = (value) => { return false; } }; +export const isRegExpMatched = (regExp, errorMessage) => { + return helpers.withParams( + { type: 'isRegExpMatched', regExp, errorMessage }, + (value) => { + if (!value) return true; + return regExp.test(value); + } + ); +}; diff --git a/src/modules/directory/modules/users/components/opened-user-general.vue b/src/modules/directory/modules/users/components/opened-user-general.vue index fd5a33d97..2563d0c1c 100644 --- a/src/modules/directory/modules/users/components/opened-user-general.vue +++ b/src/modules/directory/modules/users/components/opened-user-general.vue @@ -55,10 +55,8 @@ diff --git a/src/modules/directory/modules/users/components/opened-user.vue b/src/modules/directory/modules/users/components/opened-user.vue index e04187ca6..879c0dcdc 100644 --- a/src/modules/directory/modules/users/components/opened-user.vue +++ b/src/modules/directory/modules/users/components/opened-user.vue @@ -48,6 +48,7 @@ import { useVuelidate } from '@vuelidate/core'; import { helpers, required, requiredIf, requiredUnless } from '@vuelidate/validators'; import openedObjectMixin from '../../../../../app/mixins/objectPagesMixins/openedObjectMixin/openedObjectMixin'; +import { isRegExpMatched } from '../../../../../app/utils/validators.js'; import Logs from '../modules/logs/components/opened-user-logs.vue'; import LogsFilters from '../modules/logs/modules/filters/components/opened-user-logs-filters.vue'; import Tokens from '../modules/tokens/components/opened-user-token.vue'; @@ -56,6 +57,8 @@ import General from './opened-user-general.vue'; import License from './opened-user-license.vue'; import Roles from './opened-user-roles.vue'; import Variables from './opened-user-variables.vue'; +import { EngineSystemSettingName } from 'webitel-sdk'; +import ConfigurationAPI from '../../../../system/modules/configuration/api/configuration.js'; export default { name: 'OpenedUser', @@ -76,24 +79,29 @@ export default { }), data: () => ({ namespace: 'directory/users', + passwordRegExp: '', + validationText: '', }), - validations: { - itemInstance: { - username: { required }, - password: { - required: requiredUnless((value, item) => !!item.id), - }, - variables: { - $each: helpers.forEach({ - key: { - required: requiredIf((value, item) => !!item.value), - }, - value: { - required: requiredIf((value, item) => !!item.key), - }, - }), + validations() { + return { + itemInstance: { + username: { required }, + password: { + required: requiredUnless((value, item) => !!item.id), + isRegExpMatched: isRegExpMatched(this.passwordRegExp, this.validationText) + }, + variables: { + $each: helpers.forEach({ + key: { + required: requiredIf((value, item) => !!item.value), + }, + value: { + required: requiredIf((value, item) => !!item.key), + }, + }), + }, }, - }, + }; }, computed: { @@ -152,6 +160,23 @@ export default { return tabs; }, }, + methods: { + async checkPasswordRegExp() { + const PasswordRegExp = await ConfigurationAPI.getList({ name: EngineSystemSettingName.PasswordRegExp }); + const exportSettingsValue = PasswordRegExp.items[0]?.value; + this.passwordRegExp = new RegExp(exportSettingsValue); + }, + + async checkPasswordValidationText() { + const PasswordRegExp = await ConfigurationAPI.getList({ name: EngineSystemSettingName.PasswordValidationText }); + const exportSettingsValue = PasswordRegExp.items[0]?.value; + this.validationText = new RegExp(exportSettingsValue); + }, + }, + async mounted() { + await this.checkPasswordRegExp(); + await this.checkPasswordValidationText(); + } };