Skip to content

Commit e97b08e

Browse files
authored
hestiacp#896 2fa reset page (hestiacp#897)
1 parent b0e5250 commit e97b08e

File tree

3 files changed

+66
-16
lines changed

3 files changed

+66
-16
lines changed

bin/v-delete-user-2fa

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ sed -i '/QRCODE=/d' $USER_DATA/user.conf
5050
# Hestia #
5151
#----------------------------------------------------------#
5252

53+
log_history "2FA Disabled for $user"
54+
log_event "$OK" "$ARGUMENTS"
55+
5356
exit

web/reset2fa/index.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
session_start();
3+
define('NO_AUTH_REQUIRED',true);
4+
$TAB = 'RESET PASSWORD';
5+
6+
if (isset($_SESSION['user'])) {
7+
header("Location: /list/user");
8+
}
9+
10+
// Main include
11+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
12+
13+
// Detect language
14+
if (empty($_SESSION['language'])){
15+
$_SESSION['language'] = detect_user_language();
16+
}
17+
//Check values
18+
if(!empty($_POST['user']) && !empty($_POST['twofa'])){
19+
$error = true;
20+
$v_user = escapeshellarg($_POST['user']);
21+
$user = $_POST['user'];
22+
$twofa = $_POST['twofa'];
23+
$cmd="/usr/bin/sudo /usr/local/hestia/bin/v-list-user";
24+
exec ($cmd." ".$v_user." json", $output, $return_var);
25+
if ( $return_var == 0 ) {
26+
$data = json_decode(implode('', $output), true);
27+
if($data[$user]['TWOFA'] == $twofa){
28+
$success = true;
29+
$cmd="/usr/bin/sudo /usr/local/hestia/bin/v-delete-user-2fa";
30+
exec ($cmd." ".$v_user." json", $output, $return_var);
31+
}else{
32+
sleep(5);
33+
}
34+
}else{
35+
sleep(5);
36+
}
37+
38+
}
39+
40+
require_once '../templates/header.html';
41+
require_once '../templates/reset2fa.html';
42+
43+
?>

web/templates/reset2fa.html

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
<td>
55
<table>
66
<tr>
7-
<td style="padding: 0 10px 0 42px; height: 280px; width: 170px;">
8-
<a href="/"><img border=0 src="/images/logo.png" width="124px" height="46px" alt="Hestia Control Panel" /></a>
7+
<td style="padding: 22px 30px 0 42px; height: 280px; width: 170px;">
8+
<a href="/"><img border=0 src="/images/logo.png" alt="Hestia Control Panel" style="margin: 20px; margin-top: 64px;" /></a>
99
</td>
10-
<td style="padding: 10px 0 0 0;">
11-
<?php if ($success) { ?>
12-
<table class="login-box">
13-
<tr>
14-
<td style="padding: 12px 0 0 2px;">
15-
<?php print __('2FA Reset successfully.'); ?>
16-
</td>
17-
</tr>
18-
</table>
19-
<?php } else { ?>
20-
<form method="post" action="/reset2fa/">
10+
<td style="padding: 40px 60px 0 0;" class="animated fadeIn">
11+
<?php if($success){?>
2112
<table class="login-box">
2213
<tr>
2314
<td style="padding: 12px 0 0 2px;">
24-
<?php print __('RESET_NOTICE');?>
15+
<?php print __('2FA Reset successfully.'); ?>
2516
</td>
2617
</tr>
18+
</table>
19+
<?php }else{ ?>
20+
<form method="post" action="/reset2fa/">
21+
<table class="login-box">
22+
<tr>
23+
<td style="padding: 12px 0 0 2px;" class="login-welcome">
24+
<?php print __('Reset 2FA');?>
25+
</td>
26+
</tr>
2727
<tr>
2828
<td style="padding: 12px 0 0 2px;">
2929
<?php print __('Username');?>
@@ -44,10 +44,15 @@
4444
<input tabindex="1" type="text" size="20px" style="width:240px" name="twofa" class="vst-input">
4545
</td>
4646
</tr>
47+
<tr>
48+
<td style="padding: 12px 0 0 2px;">
49+
<?php print __('RESET_NOTICE');?>
50+
</td>
51+
</tr>
4752
<tr>
4853
<td style="padding: 20px 0 12px 0;">
54+
<input type="button" class="button cancel" value="<?php print __('Back');?>" onclick="location.href='/login/'">&nbsp;&nbsp;
4955
<input tabindex="2" type="submit" value="<?php print __('Submit');?>" class="button">
50-
<input type="button" class="button cancel" value="<?php print __('Back');?>" onclick="location.href='/login/'">
5156
</td>
5257
</tr>
5358
</table>
@@ -59,7 +64,6 @@
5964
<td colspan=2>
6065
<div class="login-bottom">
6166
<div style="height:20px"><?php if (isset($ERROR)) echo $ERROR ?></div>
62-
<a class="hestiacp" href="https://www.hestiacp.com" >hestiacp.com</a>
6367
</div>
6468
</td>
6569
</tr>

0 commit comments

Comments
 (0)