Skip to content

Commit a302fbc

Browse files
author
Kristan Kenney
committed
Add v-change-user-config-value
1 parent 4a936e3 commit a302fbc

File tree

3 files changed

+101
-18
lines changed

3 files changed

+101
-18
lines changed

bin/v-change-user-config-value

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
# info: changes user configuration value
3+
# options: USER KEY VALUE
4+
# labels: hestia
5+
#
6+
# example: v-change-user-config-value admin ROLE admin
7+
#
8+
# Changes key/value for specified user.
9+
10+
#----------------------------------------------------------#
11+
# Variable&Function #
12+
#----------------------------------------------------------#
13+
14+
# Argument definition
15+
user=$1
16+
key="$2"
17+
value="$3"
18+
19+
# Includes
20+
# shellcheck source=/usr/local/hestia/func/main.sh
21+
source $HESTIA/func/main.sh
22+
# shellcheck source=/usr/local/hestia/conf/hestia.conf
23+
source $HESTIA/conf/hestia.conf
24+
25+
#----------------------------------------------------------#
26+
# Verifications #
27+
#----------------------------------------------------------#
28+
29+
# Reading user values
30+
source $USER_DATA/user.conf
31+
32+
is_format_valid 'user' 'theme'
33+
is_object_valid 'user' 'USER' "$user"
34+
is_object_unsuspended 'user' 'USER' "$user"
35+
36+
# Perform verification if read-only mode is enabled
37+
check_hestia_demo_mode
38+
39+
#----------------------------------------------------------#
40+
# Action #
41+
#----------------------------------------------------------#
42+
43+
# Set theme value
44+
check_ckey=$(grep "^${key^^}" $USER_DATA/user.conf)
45+
if [ -z "$check_ckey" ]; then
46+
# Rebuild user configuration to repair missing value
47+
$BIN/v-rebuild-user $user
48+
fi
49+
update_user_value "$user" "${key^^}" "$value"
50+
51+
#----------------------------------------------------------#
52+
# Hestia #
53+
#----------------------------------------------------------#
54+
55+
exit

web/edit/user/index.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
$v_qrcode = $data[$v_username]['QRCODE'];
5454
$v_phpcli = $data[$v_username]['PHPCLI'];
5555
$v_role = $data[$v_username]['ROLE'];
56+
$v_login_disabled = $data[$v_username]['LOGIN_DISABLED'];
57+
$v_login_use_iplist = $data[$v_username]['LOGIN_USE_IPLIST'];
58+
$v_login_allowed_ips = $data[$v_username]['LOGIN_ALLOW_IPS'];
5659
$v_ns = $data[$v_username]['NS'];
5760
$nameservers = explode(",", $v_ns);
5861
$v_ns1 = $nameservers[0];

web/templates/pages/edit_user.html

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -130,23 +130,53 @@
130130
</td>
131131
</tr>
132132
<tr>
133-
<td class="vst-text">
134-
<?php print _('Your password must have at least');?>:
135-
<ul>
136-
<li><?php print _('8 characters long');?></li>
137-
<li><?php print _('1 uppercase & 1 lowercase character');?></li>
138-
<li><?php print _('1 number');?></li>
139-
</ul>
133+
<td>
134+
<table id="password-details">
135+
<tr>
136+
<td class="vst-text">
137+
<?php print _('Your password must have at least');?>:
138+
<ul>
139+
<li><?php print _('8 characters long');?></li>
140+
<li><?php print _('1 uppercase & 1 lowercase character');?></li>
141+
<li><?php print _('1 number');?></li>
142+
</ul>
143+
</td>
144+
</tr>
145+
<tr>
146+
<td>
147+
<label><input type="checkbox" class="vst-checkbox password-option" name="v_twofa" <?php if(!empty($v_twofa)) echo "checked=yes" ?>><?php print _('Enable 2FA');?></label>
148+
<?php if (!empty($v_twofa)) { ?>
149+
<p><?php echo _('2FA Reset Code:').' '.$v_twofa; ?></br></p>
150+
<p><?php echo _('Please scan the code below in your 2FA application:'); ?></p>
151+
<div><img class="qr-code" src="<?php echo $v_qrcode; ?>"></div>
152+
<?php } ?>
153+
</td>
154+
</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" onclick="javascript:elementHideShow('password-details')" name="v_login_disabled" <?php if ((isset($data[$user]['LOGIN_DISABLED'])) && (!empty($data[$user]['LOGIN_DISABLED'])) && ($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>
140168
</td>
141169
</tr>
142170
<tr>
143171
<td>
144-
<label><input type="checkbox" class="vst-checkbox password-option" name="v_twofa" <?php if(!empty($v_twofa)) echo "checked=yes" ?>><?php print _('Enable 2FA');?></label>
145-
<?php if (!empty($v_twofa)) { ?>
146-
<p><?php echo _('2FA Reset Code:').' '.$v_twofa; ?></br></p>
147-
<p><?php echo _('Please scan the code below in your 2FA application:'); ?></p>
148-
<div><img class="qr-code" src="<?php echo $v_qrcode; ?>"></div>
149-
<?php } ?>
172+
<table id="ip-allowlist" style="<? if ($data[$user]['LOGIN_USE_IPLIST'] === 'yes') { echo 'display: table-cell;'; } else { echo 'display: none;'; } ?>">
173+
<tr>
174+
<td>
175+
<input type="text" size="20" class="vst-input" name="v_login_allowed_ups" value="<?=htmlentities(trim($v_login_allowed_ips, "'"))?>">
176+
<input type="hidden" name="v_login_allowed_ips" value="<?=htmlentities(trim($v_login_allowed_ips, "'"))?>">
177+
</td>
178+
</tr>
179+
</table>
150180
</td>
151181
</tr>
152182
<tr>
@@ -192,11 +222,6 @@
192222
</tr>
193223
<? } ?>
194224
<? } ?>
195-
<tr>
196-
<td>
197-
<label><input type="checkbox" size="20" class="vst-checkbox" name="v_user_login_disabled" <?php if ((isset($data[$user]['LOGIN_DISABLED'])) && (!empty($data[$user]['LOGIN_DISABLED'])) && ($data[$user]['LOGIN_DISABLED'] == "yes")) echo "checked=yes" ?>><?php print _('User can not log in to Control Panel');?></label>
198-
</td>
199-
</tr>
200225
<? if ($_SESSION['POLICY_USER_CHANGE_THEME'] !== 'no') {?>
201226
<tr>
202227
<td class="vst-text input-label">

0 commit comments

Comments
 (0)