Skip to content

Commit

Permalink
#896 2fa reset page (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapmarcus committed Jul 5, 2020
1 parent b0e5250 commit e97b08e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 16 deletions.
3 changes: 3 additions & 0 deletions bin/v-delete-user-2fa
Expand Up @@ -50,4 +50,7 @@ sed -i '/QRCODE=/d' $USER_DATA/user.conf
# Hestia #
#----------------------------------------------------------#

log_history "2FA Disabled for $user"
log_event "$OK" "$ARGUMENTS"

exit
43 changes: 43 additions & 0 deletions web/reset2fa/index.php
@@ -0,0 +1,43 @@
<?php
session_start();
define('NO_AUTH_REQUIRED',true);
$TAB = 'RESET PASSWORD';

if (isset($_SESSION['user'])) {
header("Location: /list/user");
}

// Main include
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");

// Detect language
if (empty($_SESSION['language'])){
$_SESSION['language'] = detect_user_language();
}
//Check values
if(!empty($_POST['user']) && !empty($_POST['twofa'])){
$error = true;
$v_user = escapeshellarg($_POST['user']);
$user = $_POST['user'];
$twofa = $_POST['twofa'];
$cmd="/usr/bin/sudo /usr/local/hestia/bin/v-list-user";
exec ($cmd." ".$v_user." json", $output, $return_var);
if ( $return_var == 0 ) {
$data = json_decode(implode('', $output), true);
if($data[$user]['TWOFA'] == $twofa){
$success = true;
$cmd="/usr/bin/sudo /usr/local/hestia/bin/v-delete-user-2fa";
exec ($cmd." ".$v_user." json", $output, $return_var);
}else{
sleep(5);
}
}else{
sleep(5);
}

}

require_once '../templates/header.html';
require_once '../templates/reset2fa.html';

?>
36 changes: 20 additions & 16 deletions web/templates/reset2fa.html
Expand Up @@ -4,26 +4,26 @@
<td>
<table>
<tr>
<td style="padding: 0 10px 0 42px; height: 280px; width: 170px;">
<a href="/"><img border=0 src="/images/logo.png" width="124px" height="46px" alt="Hestia Control Panel" /></a>
<td style="padding: 22px 30px 0 42px; height: 280px; width: 170px;">
<a href="/"><img border=0 src="/images/logo.png" alt="Hestia Control Panel" style="margin: 20px; margin-top: 64px;" /></a>
</td>
<td style="padding: 10px 0 0 0;">
<?php if ($success) { ?>
<table class="login-box">
<tr>
<td style="padding: 12px 0 0 2px;">
<?php print __('2FA Reset successfully.'); ?>
</td>
</tr>
</table>
<?php } else { ?>
<form method="post" action="/reset2fa/">
<td style="padding: 40px 60px 0 0;" class="animated fadeIn">
<?php if($success){?>
<table class="login-box">
<tr>
<td style="padding: 12px 0 0 2px;">
<?php print __('RESET_NOTICE');?>
<?php print __('2FA Reset successfully.'); ?>
</td>
</tr>
</table>
<?php }else{ ?>
<form method="post" action="/reset2fa/">
<table class="login-box">
<tr>
<td style="padding: 12px 0 0 2px;" class="login-welcome">
<?php print __('Reset 2FA');?>
</td>
</tr>
<tr>
<td style="padding: 12px 0 0 2px;">
<?php print __('Username');?>
Expand All @@ -44,10 +44,15 @@
<input tabindex="1" type="text" size="20px" style="width:240px" name="twofa" class="vst-input">
</td>
</tr>
<tr>
<td style="padding: 12px 0 0 2px;">
<?php print __('RESET_NOTICE');?>
</td>
</tr>
<tr>
<td style="padding: 20px 0 12px 0;">
<input type="button" class="button cancel" value="<?php print __('Back');?>" onclick="location.href='/login/'">&nbsp;&nbsp;
<input tabindex="2" type="submit" value="<?php print __('Submit');?>" class="button">
<input type="button" class="button cancel" value="<?php print __('Back');?>" onclick="location.href='/login/'">
</td>
</tr>
</table>
Expand All @@ -59,7 +64,6 @@
<td colspan=2>
<div class="login-bottom">
<div style="height:20px"><?php if (isset($ERROR)) echo $ERROR ?></div>
<a class="hestiacp" href="https://www.hestiacp.com" >hestiacp.com</a>
</div>
</td>
</tr>
Expand Down

0 comments on commit e97b08e

Please sign in to comment.