mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2024-12-14 10:52:49 +02:00
[Web] Fix slow UI by switching QR provider and only generating qr image on demand
This commit is contained in:
parent
ca2ac00422
commit
6a13609bf0
13
data/web/inc/ajax/qr_gen.php
Normal file
13
data/web/inc/ajax/qr_gen.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/prerequisites.inc.php';
|
||||||
|
header('Content-Type: text/plain');
|
||||||
|
if (!isset($_SESSION['mailcow_cc_role'])) {
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['token']) && ctype_alnum($_GET['token'])) {
|
||||||
|
echo $tfa->getQRCodeImageAsDataUri($_SESSION['mailcow_cc_username'], $totp_secret);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -93,6 +93,15 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
if ($(this).val() == "totp") {
|
if ($(this).val() == "totp") {
|
||||||
$('#TOTPModal').modal('show');
|
$('#TOTPModal').modal('show');
|
||||||
|
request_token = $('#tfa-qr-img').data('totp-secret');
|
||||||
|
$.ajax({
|
||||||
|
url: '/inc/ajax/qr_gen.php',
|
||||||
|
data: {
|
||||||
|
token: request_token,
|
||||||
|
},
|
||||||
|
}).done(function (result) {
|
||||||
|
$("#tfa-qr-img").attr("src", result);
|
||||||
|
});
|
||||||
$("option:selected").prop("selected", false);
|
$("option:selected").prop("selected", false);
|
||||||
}
|
}
|
||||||
if ($(this).val() == "u2f") {
|
if ($(this).val() == "u2f") {
|
||||||
|
@ -36,7 +36,8 @@ foreach ($css_dir as $css_file) {
|
|||||||
|
|
||||||
// U2F API + T/HOTP API
|
// U2F API + T/HOTP API
|
||||||
$u2f = new u2flib_server\U2F('https://' . $_SERVER['HTTP_HOST']);
|
$u2f = new u2flib_server\U2F('https://' . $_SERVER['HTTP_HOST']);
|
||||||
$tfa = new RobThree\Auth\TwoFactorAuth($OTP_LABEL);
|
$qrprovider = new RobThree\Auth\Providers\Qr\QRServerProvider();
|
||||||
|
$tfa = new RobThree\Auth\TwoFactorAuth($OTP_LABEL, 6, 30, 'sha1', $qrprovider);
|
||||||
|
|
||||||
// Redis
|
// Redis
|
||||||
$redis = new Redis();
|
$redis = new Redis();
|
||||||
|
@ -81,7 +81,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
|
|||||||
<ol>
|
<ol>
|
||||||
<li>
|
<li>
|
||||||
<p><?=$lang['tfa']['scan_qr_code'];?></p>
|
<p><?=$lang['tfa']['scan_qr_code'];?></p>
|
||||||
<img src="<?=$tfa->getQRCodeImageAsDataUri($_SESSION['mailcow_cc_username'], $totp_secret);?>">
|
<img id="tfa-qr-img" data-totp-secret="<?=$totp_secret;?>" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=">
|
||||||
<p class="help-block"><?=$lang['tfa']['enter_qr_code'];?>:<br />
|
<p class="help-block"><?=$lang['tfa']['enter_qr_code'];?>:<br />
|
||||||
<code><?=$totp_secret;?></code>
|
<code><?=$totp_secret;?></code>
|
||||||
</p>
|
</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user