Skip to content

Commit 2a702e6

Browse files
author
Kristan Kenney
committed
Ensure status is set correctly and adjust layout
1 parent ad9f027 commit 2a702e6

File tree

2 files changed

+44
-34
lines changed

2 files changed

+44
-34
lines changed

web/edit/user/index.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,25 +179,34 @@
179179
unset($output);
180180
}
181181

182-
// Update panel login status (admin only)
182+
// Update Control Panel login disabled status (admin only)
183183
if (empty($_SESSION['error_msg'])) {
184-
if ($data[$user]['LOGIN_DISABLED'] != $_POST['v_login_disabled']) {
184+
if ($_POST['v_login_disabled'] != $data[$user]['LOGIN_DISABLED']) {
185185
if ($_POST['v_login_disabled'] == 'on') { $_POST['v_login_disabled'] = 'yes'; } else { $_POST['v_login_disabled'] = 'no'; }
186186
exec (HESTIA_CMD."v-change-user-config-value ".escapeshellarg($v_username)." LOGIN_DISABLED ".escapeshellarg($_POST['v_login_disabled']), $output, $return_var);
187187
check_return_code($return_var,$output);
188+
$data[$user]['LOGIN_DISABLED'] = $_POST['v_login_disabled'];
188189
unset($output);
189-
190-
$v_login_disabled = $_POST['v_login_disabled'];
191190
}
192191
}
193192

194-
// Change use IP allow list option (admin only)
195-
if (($v_login_use_iplist != $_POST['v_login_use_iplist']) && (empty($_SESSION['error_msg']))) {
196-
if ($_POST['v_login_use_iplist'] == 'on') { $_POST['v_login_use_iplist'] = 'yes'; } else { $_POST['v_login_use_iplist'] = 'no'; }
197-
$v_login_use_iplist = escapeshellarg($_POST['v_login_use_iplist']);
198-
exec (HESTIA_CMD."v-change-user-config-value ".escapeshellarg($v_username)." LOGIN_USE_IPLIST ".$v_login_use_iplist, $output, $return_var);
199-
check_return_code($return_var,$output);
200-
unset($output);
193+
// Update IP whitelist option
194+
if (empty($_SESSION['error_msg'])) {
195+
if ($_POST['v_login_use_iplist'] != $data[$user]['LOGIN_USE_IPLIST']) {
196+
if ($_POST['v_login_use_iplist'] == 'on') { $_POST['v_login_use_iplist'] = 'yes'; } else { $_POST['v_login_use_iplist'] = 'no'; }
197+
exec (HESTIA_CMD."v-change-user-config-value ".escapeshellarg($v_username)." LOGIN_USE_IPLIST ".escapeshellarg($_POST['v_login_use_iplist']), $output, $return_var);
198+
if ($_POST['v_login_use_iplist'] === 'no') {
199+
exec (HESTIA_CMD."v-change-user-config-value ".escapeshellarg($v_username)." LOGIN_ALLOW_IPS ''", $output, $return_var);
200+
$v_login_allowed_ips = '';
201+
} else {
202+
exec (HESTIA_CMD."v-change-user-config-value ".escapeshellarg($v_username)." LOGIN_ALLOW_IPS ".escapeshellarg($_POST['v_login_allowed_ips']), $output, $return_var);
203+
unset($v_login_allowed_ips);
204+
$v_login_allowed_ips = $_POST['v_login_allowed_ips'];
205+
}
206+
check_return_code($return_var,$output);
207+
$data[$user]['LOGIN_USE_IPLIST'] = $_POST['v_login_use_iplist'];
208+
unset($output);
209+
}
201210
}
202211

203212
// Change package (admin only)

web/templates/pages/edit_user.html

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,18 @@
129129
<meter max="4" id="meter"></meter>
130130
</td>
131131
</tr>
132+
<? if ($_SESSION['userContext'] === 'admin') {?>
133+
<tr>
134+
<td>
135+
<label><input type="checkbox" size="20" class="vst-checkbox" onclick="javascript:elementHideShow('password-details')" name="v_login_disabled" <?php if ($data[$user]['LOGIN_DISABLED'] == "yes") echo "checked=yes" ?>><?php print _('Do not allow user to log in to Control Panel');?></label>
136+
</td>
137+
</tr>
138+
<? } ?>
132139
<tr>
133140
<td>
134-
<table id="password-details">
141+
<table id="password-details" style="<?php if ($data[$user]['LOGIN_DISABLED'] == "yes") { echo 'display: none;'; } else { echo 'display: table-cell;'; }?>">
135142
<tr>
136-
<td class="vst-text">
143+
<td class="vst-text step-top">
137144
<?php print _('Your password must have at least');?>:
138145
<ul>
139146
<li><?php print _('8 characters long');?></li>
@@ -152,28 +159,20 @@
152159
<?php } ?>
153160
</td>
154161
</tr>
155-
</table>
156-
</td>
157-
</tr>
158-
<? if ($_SESSION['userContext'] === 'admin') {?>
159-
<tr>
160-
<td>
161-
<label><input type="checkbox" size="20" class="vst-checkbox" name="v_login_disabled" <?php if ($data[$user]['LOGIN_DISABLED'] == "yes") echo "checked=yes" ?>><?php print _('User can not log in to Control Panel');?></label>
162-
</td>
163-
</tr>
164-
<? } ?>
165-
<tr>
166-
<td>
167-
<label><input type="checkbox" size="20" class="vst-checkbox" onclick="javascript:elementHideShow('ip-allowlist')" name="v_login_use_iplist" <?php if ($data[$user]['LOGIN_USE_IPLIST'] === "yes") echo "checked=yes" ?>><?php print _('Only allow logins from certain IP addresses');?></label>
168-
</td>
169-
</tr>
170-
<tr>
171-
<td>
172-
<table id="ip-allowlist" style="<? if ($data[$user]['LOGIN_USE_IPLIST'] === 'yes') { echo 'display: table-cell;'; } else { echo 'display: none;'; } ?>">
173162
<tr>
174163
<td>
175-
<input type="text" size="20" class="vst-input" placeholder="<?=_('Example: 127.0.0.1,192.168.1.100');?>" name="v_login_allowed_ips" value="<?=htmlentities(trim($v_login_allowed_ips, "'"))?>">
176-
<input type="hidden" name="v_login_allowed_ips" value="<?=htmlentities(trim($v_login_allowed_ips, "'"))?>">
164+
<label><input type="checkbox" size="20" class="vst-checkbox" onclick="javascript:elementHideShow('ip-allowlist')" name="v_login_use_iplist" <?php if ($data[$user]['LOGIN_USE_IPLIST'] === "yes") echo "checked=yes" ?>><?php print _('Use IP address allow list for login attempts');?></label>
165+
</td>
166+
</tr>
167+
<tr>
168+
<td>
169+
<table id="ip-allowlist" style="<? if ($data[$user]['LOGIN_USE_IPLIST'] === 'yes') { echo 'display: table-cell;'; } else { echo 'display: none;'; } ?>">
170+
<tr>
171+
<td>
172+
<input type="text" size="20" class="vst-input" placeholder="<?=_('Example: 127.0.0.1,192.168.1.100');?>" name="v_login_allowed_ips" value="<?=htmlentities(trim($v_login_allowed_ips, "'"))?>">
173+
</td>
174+
</tr>
175+
</table>
177176
</td>
178177
</tr>
179178
</table>
@@ -250,9 +249,10 @@
250249
</td>
251250
</tr>
252251
<?}?>
252+
<? if ($_GET['user'] === $_SESSION['user']) { ?>
253253
<tr>
254254
<td class="vst-text input-label">
255-
<?php print _('Default sort order');?>
255+
<?php print _('Default list sort order');?>
256256
</td>
257257
</tr>
258258
<tr>
@@ -263,6 +263,7 @@
263263
</select>
264264
</td>
265265
</tr>
266+
<? } ?>
266267
<? if ($_SESSION['userContext'] === 'admin') {?>
267268
<tr>
268269
<td class="vst-text input-label">

0 commit comments

Comments
 (0)