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/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.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(); + } }; 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 61b15720e..8fc591712 100644 --- a/src/modules/system/modules/configuration/components/configuration-popup.vue +++ b/src/modules/system/modules/configuration/components/configuration-popup.vue @@ -152,6 +152,7 @@ export default { }, }; } + const defaultStringConfig = { itemInstance: { value: { @@ -177,6 +178,10 @@ export default { return deepmerge(defaults, defaultSelectConfig); case EngineSystemSettingName.ChatAiConnection: return deepmerge(defaults, defaultStringConfig); + 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 8c3bdc6f8..53c60dec2 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', [EngineSystemSettingName.ChatAiConnection]: 'string', }, );