Skip to content

Commit 615c9d3

Browse files
committed
1 parent c75a4ce commit 615c9d3

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

Diff for: edit_2fa.cgi

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
require './virtual-server-lib.pl';
55
&ReadParse();
6-
&can_2fa() || &error($text{'2fa_ecannot'});
6+
&can_user_2fa() || &can_master_reseller_2fa() || &error($text{'2fa_ecannot'});
77

88
&ui_print_header(undef, $text{'2fa_title'}, "");
99

Diff for: lang/en

+2-1
Original file line numberDiff line numberDiff line change
@@ -8246,7 +8246,8 @@ deftmplt_tmpltpagefooteraboutcont=Contact
82468246
2fa_cancel=Cancel Two-Factor
82478247
2fa_header=Two-Factor Options
82488248
2fa_err=Failed to save two-factor authentication
8249-
2fa_enrolling=Enrolling for two-factor with $1 ...
8249+
2fa_enrolling=Enrolling for two-factor authentication with $1 ..
8250+
2fa_ecannot=You are not allowed to manage two-factor authentication
82508251

82518252
rcert_err=Failed to delete certificate
82528253
rcert_ecert=Virtual server has no certificate to remove

Diff for: save_2fa.cgi

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require './virtual-server-lib.pl';
55
&ReadParse();
66
&error_setup($text{'2fa_err'});
7-
&can_2fa() || &error($text{'2fa_ecannot'});
7+
&can_user_2fa() || &can_master_reseller_2fa() || &error($text{'2fa_ecannot'});
88

99
# Get current status
1010
&foreign_require("acl");

Diff for: virtual-server-lib-funcs.pl

+19-4
Original file line numberDiff line numberDiff line change
@@ -11564,12 +11564,20 @@ sub can_passwd
1156411564
}
1156511565

1156611566
# Returns 1 if the user can enroll for 2fa
11567-
sub can_2fa
11567+
sub can_user_2fa
11568+
{
11569+
my %miniserv;
11570+
&get_miniserv_config(\%miniserv);
11571+
return $miniserv{'twofactor_provider'} && $access{'edit_passwd'};
11572+
}
11573+
11574+
# Return 1 if the master admin or reseller can enroll for 2fa
11575+
sub can_master_reseller_2fa
1156811576
{
1156911577
my %miniserv;
1157011578
&get_miniserv_config(\%miniserv);
1157111579
return $miniserv{'twofactor_provider'} &&
11572-
(&reseller_admin() || $access{'edit_passwd'});
11580+
(&master_admin() || &reseller_admin());
1157311581
}
1157411582

1157511583
# Returns 1 if the user can change a domain's external IP address
@@ -13722,8 +13730,8 @@ sub get_domain_actions
1372213730
});
1372313731
}
1372413732

13725-
if (&can_2fa()) {
13726-
# Twofactor enroll button
13733+
if (&can_user_2fa()) {
13734+
# Twofactor enroll button for the user
1372713735
push(@rv, { 'page' => 'edit_2fa.cgi',
1372813736
'title' => $text{'edit_change2fa'},
1372913737
'desc' => $text{'edit_change2fadesc'},
@@ -14074,6 +14082,13 @@ sub get_all_global_links
1407414082
'icon' => 'wizard' });
1407514083
}
1407614084

14085+
# Twofactor enroll button for master admins and resellers
14086+
if (&can_master_reseller_2fa()) {
14087+
push(@rv, { 'url' => "$vm/edit_2fa.cgi",
14088+
'title' => $text{'edit_change2fa'},
14089+
'cat' => 'setting' });
14090+
}
14091+
1407714092
# Add creation-related links
1407814093
my ($dleft, $dreason, $dmax, $dhide) = &count_domains("realdoms");
1407914094
my ($aleft, $areason, $amax, $ahide) = &count_domains("aliasdoms");

0 commit comments

Comments
 (0)