|
|
@ -16,15 +16,26 @@ if (userHasTOTP($_SESSION['username'])) {
|
|
|
|
. lang("remove 2fa", false) . '</a>';
|
|
|
|
. lang("remove 2fa", false) . '</a>';
|
|
|
|
} else if ($_GET['2fa'] == "generate") {
|
|
|
|
} else if ($_GET['2fa'] == "generate") {
|
|
|
|
$codeuri = newTOTP($_SESSION['username']);
|
|
|
|
$codeuri = newTOTP($_SESSION['username']);
|
|
|
|
|
|
|
|
$userdata = $database->select('accounts', ['email', 'authsecret', 'realname'], ['username' => $_SESSION['username']])[0];
|
|
|
|
|
|
|
|
$label = SYSTEM_NAME . ":" . is_null($userdata['email']) ? $userdata['realname'] : $userdata['email'];
|
|
|
|
|
|
|
|
$issuer = SYSTEM_NAME;
|
|
|
|
$qrCode = new QrCode($codeuri);
|
|
|
|
$qrCode = new QrCode($codeuri);
|
|
|
|
$qrCode->setSize(200);
|
|
|
|
$qrCode->setSize(200);
|
|
|
|
$qrCode->setErrorCorrection("H");
|
|
|
|
$qrCode->setErrorCorrection("H");
|
|
|
|
$qrcode = $qrCode->getDataUri();
|
|
|
|
$qrcode = $qrCode->getDataUri();
|
|
|
|
$totp = Factory::loadFromProvisioningUri($codeuri);
|
|
|
|
$totp = Factory::loadFromProvisioningUri($codeuri);
|
|
|
|
$codesecret = $totp->getSecret();
|
|
|
|
$codesecret = $totp->getSecret();
|
|
|
|
$chunk_secret = trim(chunk_split($codesecret, 8, ' '));
|
|
|
|
$chunk_secret = trim(chunk_split($codesecret, 4, ' '));
|
|
|
|
|
|
|
|
$lang_manualsetup = lang("manual setup", false);
|
|
|
|
|
|
|
|
$lang_secretkey = lang("secret key", false);
|
|
|
|
|
|
|
|
$lang_label = lang("label", false);
|
|
|
|
|
|
|
|
$lang_issuer = lang("issuer", false);
|
|
|
|
|
|
|
|
$lang_entercode = lang("enter otp code", false);
|
|
|
|
$APPS["setup_2fa"]["content"] = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . lang("scan 2fa qrcode", false) . '</div>' . <<<END
|
|
|
|
$APPS["setup_2fa"]["content"] = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . lang("scan 2fa qrcode", false) . '</div>' . <<<END
|
|
|
|
<style nonce="$SECURE_NONCE">
|
|
|
|
<style nonce="$SECURE_NONCE">
|
|
|
|
|
|
|
|
.margintop-15px {
|
|
|
|
|
|
|
|
margin-top: 15px;
|
|
|
|
|
|
|
|
}
|
|
|
|
.mono-chunk {
|
|
|
|
.mono-chunk {
|
|
|
|
text-align: center;
|
|
|
|
text-align: center;
|
|
|
|
font-size: 110%;
|
|
|
|
font-size: 110%;
|
|
|
@ -32,8 +43,9 @@ if (userHasTOTP($_SESSION['username'])) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</style>
|
|
|
|
<img src="$qrcode" class="img-responsive qrcode" />
|
|
|
|
<img src="$qrcode" class="img-responsive qrcode" />
|
|
|
|
<div class="well well-sm mono-chunk">$chunk_secret</div>
|
|
|
|
<form action="action.php" method="POST" class="margintop-15px">
|
|
|
|
<form action="action.php" method="POST">
|
|
|
|
<input type="text" name="totpcode" class="form-control" placeholder="$lang_entercode" minlength=6 maxlength=6 required />
|
|
|
|
|
|
|
|
<br />
|
|
|
|
<input type="hidden" name="action" value="add2fa" />
|
|
|
|
<input type="hidden" name="action" value="add2fa" />
|
|
|
|
<input type="hidden" name="source" value="security" />
|
|
|
|
<input type="hidden" name="source" value="security" />
|
|
|
|
<input type="hidden" name="secret" value="$codesecret" />
|
|
|
|
<input type="hidden" name="secret" value="$codesecret" />
|
|
|
@ -42,6 +54,17 @@ END
|
|
|
|
. lang("confirm 2fa", false) . <<<END
|
|
|
|
. lang("confirm 2fa", false) . <<<END
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<div class="panel panel-default margintop-15px">
|
|
|
|
|
|
|
|
<div class="panel-body">
|
|
|
|
|
|
|
|
<b>$lang_manualsetup</b>
|
|
|
|
|
|
|
|
<br /><label>$lang_secretkey:</label>
|
|
|
|
|
|
|
|
<div class="well well-sm mono-chunk">$chunk_secret</div>
|
|
|
|
|
|
|
|
<br /><label>$lang_label:</label>
|
|
|
|
|
|
|
|
<div class="well well-sm mono-chunk">$label</div>
|
|
|
|
|
|
|
|
<br /><label>$lang_issuer:</label>
|
|
|
|
|
|
|
|
<div class="well well-sm mono-chunk">$issuer</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
END;
|
|
|
|
END;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$APPS["setup_2fa"]["content"] = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . lang("2fa explained", false) . '</div>'
|
|
|
|
$APPS["setup_2fa"]["content"] = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . lang("2fa explained", false) . '</div>'
|
|
|
|