Small panel bugfixes

This commit is contained in:
Pinga 2024-11-26 12:38:02 +02:00
parent a30f71e10a
commit 9cf54beb24
3 changed files with 13 additions and 6 deletions

View file

@ -32,9 +32,10 @@ class AuthController extends Controller
* @throws \DI\NotFoundException * @throws \DI\NotFoundException
*/ */
public function createLogin(Request $request, Response $response){ public function createLogin(Request $request, Response $response){
return view($response,'auth/login.twig'); $isWebAuthnEnabled = envi('WEB_AUTHN_ENABLED') === 'true';
return view($response, 'auth/login.twig', ['isWebaEnabled' => $isWebaEnabled]);
} }
/** /**
* Show 2FA verification form. * Show 2FA verification form.
* *

View file

@ -39,7 +39,9 @@ class ReportsController extends Controller
'registrar' => $registrar['name'], 'registrar' => $registrar['name'],
'currency' => $currency, 'currency' => $currency,
'number' => $domainCount[0]['count'] ?? 0, 'number' => $domainCount[0]['count'] ?? 0,
'share' => number_format(($domainCount[0]['count'] ?? 0) / $numT * 100, 2), 'share' => $numT > 0
? number_format(($domainCount[0]['count'] ?? 0) / $numT * 100, 2)
: '0.00',
'earnings' => $earnings[0]['amt'] ?? 0 'earnings' => $earnings[0]['amt'] ?? 0
]; ];
} }

View file

@ -44,6 +44,7 @@
</div> </div>
</form> </form>
</div> </div>
{% if isWebaEnabled %}
<div class="hr-text">or</div> <div class="hr-text">or</div>
<div class="card-body"> <div class="card-body">
<div class="row"> <div class="row">
@ -53,6 +54,7 @@
</button></div> </button></div>
</div> </div>
</div> </div>
{% endif %}
</div> </div>
</div> </div>
</div> </div>
@ -60,10 +62,12 @@
<script> <script>
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
{% if isWebaEnabled %}
const loginButton = document.getElementById('loginWebAuthnButton'); const loginButton = document.getElementById('loginWebAuthnButton');
{% endif %}
const emailInput = document.querySelector('input[name="email"]'); const emailInput = document.querySelector('input[name="email"]');
const passwordInput = document.querySelector('input[name="password"]'); const passwordInput = document.querySelector('input[name="password"]');
{% if isWebaEnabled %}
loginButton.addEventListener('click', async function() { loginButton.addEventListener('click', async function() {
try { try {
if (!window.fetch || !navigator.credentials || !navigator.credentials.create) { if (!window.fetch || !navigator.credentials || !navigator.credentials.create) {
@ -146,7 +150,7 @@ document.addEventListener('DOMContentLoaded', function() {
} }
}); });
/** /**
* convert RFC 1342-like base64 strings to array buffer * convert RFC 1342-like base64 strings to array buffer
* @param {mixed} obj * @param {mixed} obj
@ -191,7 +195,7 @@ document.addEventListener('DOMContentLoaded', function() {
} }
return window.btoa(binary); return window.btoa(binary);
} }
{% endif %}
const togglePasswordBtn = document.querySelector('.input-group-text a'); const togglePasswordBtn = document.querySelector('.input-group-text a');
togglePasswordBtn.addEventListener('click', function() { togglePasswordBtn.addEventListener('click', function() {