@@ -28,6 +28,16 @@ if (!isset($_SESSION["logged_in"]) || $_SESSION["logged_in"] !== true) {
|
|||||||
.modal-backdrop.modal-front-backdrop {
|
.modal-backdrop.modal-front-backdrop {
|
||||||
z-index: 1060;
|
z-index: 1060;
|
||||||
}
|
}
|
||||||
|
.qr-wrap {
|
||||||
|
display: inline-block;
|
||||||
|
background: #fff;
|
||||||
|
padding: 16px;
|
||||||
|
margin: 0 16px 16px;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
.qr-secret {
|
||||||
|
margin: 0 16px 16px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -199,7 +209,18 @@ if (!isset($_SESSION["logged_in"]) || $_SESSION["logged_in"] !== true) {
|
|||||||
<div class="modal-body" id="twofaModalMessage">
|
<div class="modal-body" id="twofaModalMessage">
|
||||||
<!-- Success message will go here -->
|
<!-- Success message will go here -->
|
||||||
</div>
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
<div class="qr-wrap">
|
||||||
<div id="qrcode"></div>
|
<div id="qrcode"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="qr-secret">
|
||||||
|
<label for="twofa-secret" class="form-label">Secret</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" id="twofa-secret" class="form-control" readonly>
|
||||||
|
<button type="button" class="btn btn-outline-secondary" onclick="copy2FaSecret()">Copy</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="p-3">
|
<div class="p-3">
|
||||||
<input type="text" id="twofa-confirm-pin" class="form-control" placeholder="Current 2FA code">
|
<input type="text" id="twofa-confirm-pin" class="form-control" placeholder="Current 2FA code">
|
||||||
</div>
|
</div>
|
||||||
@@ -458,12 +479,24 @@ if (!isset($_SESSION["logged_in"]) || $_SESSION["logged_in"] !== true) {
|
|||||||
function show2FaModal(message,secret) {
|
function show2FaModal(message,secret) {
|
||||||
document.getElementById('twofaModalMessage').textContent = message;
|
document.getElementById('twofaModalMessage').textContent = message;
|
||||||
document.getElementById('qrcode').innerHTML = '';
|
document.getElementById('qrcode').innerHTML = '';
|
||||||
|
document.getElementById('twofa-secret').value = secret;
|
||||||
document.getElementById('twofa-confirm-pin').value = '';
|
document.getElementById('twofa-confirm-pin').value = '';
|
||||||
const errorModal = new bootstrap.Modal(document.getElementById('twofaModal'));
|
const errorModal = new bootstrap.Modal(document.getElementById('twofaModal'));
|
||||||
generate2FAQRCode("Jakach Login",'<?php echo($_SESSION["username"]) ?>',secret);
|
generate2FAQRCode("Jakach Login",'<?php echo($_SESSION["username"]) ?>',secret);
|
||||||
errorModal.show();
|
errorModal.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function copy2FaSecret() {
|
||||||
|
const secretInput = document.getElementById('twofa-secret');
|
||||||
|
secretInput.select();
|
||||||
|
secretInput.setSelectionRange(0, secretInput.value.length);
|
||||||
|
if (navigator.clipboard) {
|
||||||
|
await navigator.clipboard.writeText(secretInput.value);
|
||||||
|
} else {
|
||||||
|
document.execCommand('copy');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function confirm2FaEnrollment() {
|
async function confirm2FaEnrollment() {
|
||||||
const pin = document.getElementById('twofa-confirm-pin').value.trim();
|
const pin = document.getElementById('twofa-confirm-pin').value.trim();
|
||||||
if (!pin) {
|
if (!pin) {
|
||||||
|
|||||||
Reference in New Issue
Block a user