Skip to content

Commit ec4e15b

Browse files
committed
Merge branch 'general-settings' into develop: Enhanced password validation and REST API integration
2 parents a7ceab9 + 0e9f844 commit ec4e15b

11 files changed

Lines changed: 198 additions & 49 deletions

File tree

sites/admin-cabinet/assets/js/pbx/GeneralSettings/general-settings-modify.js

Lines changed: 64 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sites/admin-cabinet/assets/js/pbx/GeneralSettings/password-validator.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sites/admin-cabinet/assets/js/src/GeneralSettings/general-settings-modify.js

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,14 @@ const generalSettingsModify = {
382382
// Populate form with the received data
383383
generalSettingsModify.populateForm(response.data);
384384
generalSettingsModify.dataLoaded = true;
385+
386+
// Show warnings for default passwords after DOM update
387+
if (response.data.passwordValidation) {
388+
// Use setTimeout to ensure DOM is updated after populateForm
389+
setTimeout(() => {
390+
generalSettingsModify.showDefaultPasswordWarnings(response.data.passwordValidation);
391+
}, 100);
392+
}
385393
} else if (response && response.messages) {
386394
console.error('API Error:', response.messages);
387395
// Show error message if available
@@ -500,6 +508,74 @@ const generalSettingsModify = {
500508
}
501509
},
502510

511+
/**
512+
* Show warnings for default passwords
513+
* @param {object} validation - Password validation results from API
514+
*/
515+
showDefaultPasswordWarnings(validation) {
516+
// Remove any existing password-validate messages first
517+
$('.password-validate').remove();
518+
519+
// Show warning for default Web Admin password
520+
if (validation.isDefaultWebPassword) {
521+
// Find the password fields group - try multiple selectors
522+
let $webPasswordFields = $('#WebAdminPassword').closest('.two.fields');
523+
524+
if ($webPasswordFields.length === 0) {
525+
// Try alternative selector if the first one doesn't work
526+
$webPasswordFields = $('#WebAdminPassword').parent().parent();
527+
}
528+
529+
if ($webPasswordFields.length > 0) {
530+
// Create warning message
531+
const warningHtml = `
532+
<div class="ui negative icon message password-validate">
533+
<i class="exclamation triangle icon"></i>
534+
<div class="content">
535+
<div class="header">${globalTranslate.gs_SetPassword || 'Security Warning'}</div>
536+
<p>${globalTranslate.gs_SetPasswordInfo || 'You are using the default password. Please change it for security.'}</p>
537+
</div>
538+
</div>
539+
`;
540+
541+
// Insert warning before the password fields
542+
$webPasswordFields.before(warningHtml);
543+
}
544+
}
545+
546+
// Show warning for default SSH password
547+
if (validation.isDefaultSSHPassword) {
548+
// Check if SSH password login is enabled
549+
const sshPasswordDisabled = $('#SSHDisablePasswordLogins').checkbox('is checked');
550+
551+
if (!sshPasswordDisabled) {
552+
// Find the SSH password fields group
553+
let $sshPasswordFields = $('#SSHPassword').closest('.two.fields');
554+
555+
if ($sshPasswordFields.length === 0) {
556+
// Try alternative selector
557+
$sshPasswordFields = $('#SSHPassword').parent().parent();
558+
}
559+
560+
if ($sshPasswordFields.length > 0) {
561+
// Create warning message
562+
const warningHtml = `
563+
<div class="ui negative icon message password-validate">
564+
<i class="exclamation triangle icon"></i>
565+
<div class="content">
566+
<div class="header">${globalTranslate.gs_SetPassword || 'Security Warning'}</div>
567+
<p>${globalTranslate.gs_SetPasswordInfo || 'You are using the default password. Please change it for security.'}</p>
568+
</div>
569+
</div>
570+
`;
571+
572+
// Insert warning before the SSH password fields
573+
$sshPasswordFields.before(warningHtml);
574+
}
575+
}
576+
}
577+
},
578+
503579
/**
504580
* Load sound file values with HTML representation
505581
* @param {object} settings - Settings data from API
@@ -1137,7 +1213,11 @@ const generalSettingsModify = {
11371213
generalSettingsModify.$formObj.form('set value', 'WebAdminPasswordRepeat', generalSettingsModify.hiddenPassword);
11381214
generalSettingsModify.$formObj.form('set value', 'SSHPassword', generalSettingsModify.hiddenPassword);
11391215
generalSettingsModify.$formObj.form('set value', 'SSHPasswordRepeat', generalSettingsModify.hiddenPassword);
1140-
$('.password-validate').remove();
1216+
1217+
// Remove password validation warnings after successful save
1218+
$('.password-validate').fadeOut(300, function() {
1219+
$(this).remove();
1220+
});
11411221
}
11421222

11431223
// Check delete all conditions if needed

sites/admin-cabinet/assets/js/src/GeneralSettings/password-validator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const passwordValidator = {
8080
if ($sshPassword.length > 0) {
8181
$sshPassword.on('input', (e) => {
8282
const password = e.target.value;
83-
const sshDisabled = $('#SSHDisableSSHPassword').checkbox('is checked');
83+
const sshDisabled = $('#SSHDisablePasswordLogins').checkbox('is checked');
8484

8585
if (!sshDisabled && password && password !== 'xxxxxxx') {
8686
PasswordScore.checkPassStrength({

src/AdminCabinet/Controllers/GeneralSettingsController.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ public function modifyAction(): void
5555
}
5656
}
5757

58-
// Initialize empty array for simple passwords - will be checked asynchronously
59-
$this->view->simplePasswords = [];
60-
61-
// Check if WEBHTTPSPrivateKey exists (without exposing the actual value)
62-
$privateKey = PbxSettings::getValueByKey(PbxSettings::WEB_HTTPS_PRIVATE_KEY);
63-
$this->view->WEBHTTPSPrivateKeyExists = !empty($privateKey);
6458

6559
// Create an instance of the GeneralSettingsEditForm and assign it to the view
6660
// Pass default structure with empty values

src/AdminCabinet/Views/GeneralSettings/passwords.volt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11

2-
{% for field in simplePasswords %}
3-
{% if field === 'WebAdminPassword' %}
4-
<div class="ui negative message password-validate">
5-
<div class="header">
6-
{{ t._('gs_SetPassword') }}
7-
</div>
8-
<p>{{ t._('gs_SetPasswordInfo') }}</p>
9-
</div>
10-
{% endif %}
11-
{% endfor %}
12-
132
<div class="field">
143
<label>{{ t._('gs_WebAdminLogin') }}</label>
154
{{ form.render('WebAdminLogin') }}
@@ -32,7 +21,4 @@
3221
</div>
3322
</div>
3423
</div>
35-
</div>
36-
<div class="ui message">
37-
{{ t._('gs_DefaultPasswordWarning') }}
3824
</div>

src/AdminCabinet/Views/GeneralSettings/ssh.volt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@
1818
</div>
1919
</div>
2020
<div class="ui basic segment" id="only-if-password-enabled">
21-
{% for field in simplePasswords %}
22-
{% if field === 'SSHPassword' %}
23-
<div class="ui negative message password-validate">
24-
<div class="header">
25-
{{ t._('gs_SetPassword') }}
26-
</div>
27-
<p>{{ t._('gs_SetPasswordInfo') }}</p>
28-
</div>
29-
{% endif %}
30-
{% endfor %}
3121
<div class="two fields">
3222
<div class="field">
3323
<label>{{ t._('gs_SSHPassword') }}</label>

src/AdminCabinet/Views/GeneralSettings/web.volt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,5 @@
2828
<i class="small info circle icon field-info-icon"
2929
data-field="WEBHTTPSPrivateKey"></i>
3030
</label>
31-
{% if WEBHTTPSPrivateKeyExists %}
32-
{{ form.render('WEBHTTPSPrivateKey', ['data-has-value': 'true', 'data-field-type': 'certificate-private']) }}
33-
{% else %}
34-
{{ form.render('WEBHTTPSPrivateKey', ['data-field-type': 'certificate-private']) }}
35-
{% endif %}
31+
{{ form.render('WEBHTTPSPrivateKey', ['data-field-type': 'certificate-private']) }}
3632
</div>

src/Common/Messages/ru/GeneralSettings.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@
136136
'gs_WebAdminPasswordRepeat' => 'Повторите ввод пароля',
137137
'gs_SSHPasswordRepeat' => 'Повторите ввод пароля',
138138
'gs_Passwords' => 'Пароль WEB интерфейса',
139-
'gs_DefaultPasswordWarning' => 'Не используйте стандартный логин и пароль администратора системы',
140139
'gs_ValidateEmptyWebPassword' => 'Пароль админки не может быть пустым',
141140
'gs_ValidateWeakWebPassword' => 'Пароль WEB должен быть длиннее 4х символов',
142141
'gs_ValidateWebPasswordsFieldDifferent' => 'Пароль web интерфейса введен некорректно',

src/Core/Asterisk/Configs/SIPConf.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,9 @@ private function generateProviderEndpoint(array $provider, array $manual_attribu
11151115
'language' => $language,
11161116
'aors' => $provider['uniqid'],
11171117
'timers' => 'no',
1118-
'rtp_timeout' => '30',
1119-
'rtp_timeout_hold' => '30',
1118+
'rtp_keepalive' => '0',
1119+
'rtp_timeout' => '60',
1120+
'rtp_timeout_hold' => '300',
11201121
];
11211122

11221123
if (!empty($provider['transport'])) {
@@ -1347,8 +1348,9 @@ private function generatePeerEndpoint(
13471348
'outbound_auth' => $peer['extension'],
13481349
'acl' => "acl_{$peer['extension']}",
13491350
'timers' => 'no',
1350-
'rtp_timeout' => '30',
1351-
'rtp_timeout_hold' => '30',
1351+
'rtp_timeout' => '120',
1352+
'rtp_timeout_hold' => '600',
1353+
'rtp_keepalive' => '30',
13521354
'message_context' => 'messages',
13531355
];
13541356

0 commit comments

Comments
 (0)