Small interface improvements

This commit is contained in:
Pinga 2024-12-07 23:42:45 +02:00
parent 7571831f88
commit f3c7514c93
3 changed files with 19 additions and 3 deletions

View file

@ -68,12 +68,14 @@ class ProfileController extends Controller
'SELECT * FROM users_webauthn WHERE user_id = ? ORDER BY created_at DESC LIMIT 5', 'SELECT * FROM users_webauthn WHERE user_id = ? ORDER BY created_at DESC LIMIT 5',
[$userId] [$userId]
); );
$isWebAuthnEnabled = (envi('WEB_AUTHN_ENABLED') === 'true') ? true : false;
if ($is_2fa_activated) { if ($is_2fa_activated) {
return view($response,'admin/profile/profile.twig',['email' => $email, 'username' => $username, 'status' => $status, 'role' => $role, 'csrf_name' => $csrfName, 'csrf_value' => $csrfValue]); return view($response,'admin/profile/profile.twig',['email' => $email, 'username' => $username, 'status' => $status, 'role' => $role, 'csrf_name' => $csrfName, 'csrf_value' => $csrfValue]);
} else if ($is_weba_activated) { } else if ($is_weba_activated) {
return view($response,'admin/profile/profile.twig',['email' => $email, 'username' => $username, 'status' => $status, 'role' => $role, 'qrcodeDataUri' => $qrcodeDataUri, 'secret' => $secret, 'csrf_name' => $csrfName, 'csrf_value' => $csrfValue, 'weba' => $is_weba_activated]); return view($response,'admin/profile/profile.twig',['email' => $email, 'username' => $username, 'status' => $status, 'role' => $role, 'qrcodeDataUri' => $qrcodeDataUri, 'secret' => $secret, 'csrf_name' => $csrfName, 'csrf_value' => $csrfValue, 'weba' => $is_weba_activated]);
} else { } else {
return view($response,'admin/profile/profile.twig',['email' => $email, 'username' => $username, 'status' => $status, 'role' => $role, 'qrcodeDataUri' => $qrcodeDataUri, 'secret' => $secret, 'csrf_name' => $csrfName, 'csrf_value' => $csrfValue]); return view($response,'admin/profile/profile.twig',['email' => $email, 'username' => $username, 'status' => $status, 'role' => $role, 'qrcodeDataUri' => $qrcodeDataUri, 'secret' => $secret, 'csrf_name' => $csrfName, 'csrf_value' => $csrfValue, 'isWebaEnabled' => $isWebAuthnEnabled]);
} }
} }

View file

@ -177,11 +177,25 @@
</div> </div>
</div> </div>
{% else %} {% else %}
{% if isWebaEnabled %}
<div class="card-body"> <div class="card-body">
<h3 class="card-title">{{ __('WebAuthn Authentication') }}</h3> <h3 class="card-title">{{ __('WebAuthn Authentication') }}</h3>
<p>{{ __('Secure your account with WebAuthn. Click the button below to register your device for passwordless sign-in.') }}</p> <p>{{ __('Secure your account with WebAuthn. Click the button below to register your device for passwordless sign-in.') }}</p>
<button type="button" class="btn btn-primary" id="connectWebAuthnButton">{{ __('Connect WebAuthn Device') }}</button> <button type="button" class="btn btn-primary" id="connectWebAuthnButton">{{ __('Connect WebAuthn Device') }}</button>
</div> </div>
{% else %}
<div class="card-body">
<h3 class="card-title">{{ __('WebAuthn Authentication') }}<span class="badge bg-red text-red-fg ms-2">{{ __('Disabled') }}</span></h3>
<p>{{ __('WebAuthn is currently disabled for this installation. To enable WebAuthn authentication, follow these steps:') }}</p>
<ol>
<li>{{ __('Edit the environment configuration file located at:') }} <code>/var/www/cp/.env</code></li>
<li>{{ __('Find or add the following line:') }}</li>
<pre><code>WEB_AUTHN_ENABLED=true</code></pre>
<li>{{ __('Save the changes and reload the server (Caddy) using the following command:') }}</li>
<pre><code>sudo systemctl reload caddy</code></pre>
</ol>
</div>
{% endif %}
{% endif %} {% endif %}
</div> </div>
<div class="card tab-pane" id="tabs-log"> <div class="card tab-pane" id="tabs-log">

View file

@ -5,7 +5,7 @@
var table; var table;
document.addEventListener("DOMContentLoaded", function(){ document.addEventListener("DOMContentLoaded", function(){
{% if isWebaEnabled %}
const connectButton = document.getElementById('connectWebAuthnButton'); const connectButton = document.getElementById('connectWebAuthnButton');
connectButton.addEventListener('click', async function() { connectButton.addEventListener('click', async function() {
@ -124,7 +124,7 @@
} }
return window.btoa(binary); return window.btoa(binary);
} }
{% endif %}
table = new Tabulator("#auditTable", { table = new Tabulator("#auditTable", {
ajaxURL:"/api/records/users_audit", // Set the URL for your JSON data ajaxURL:"/api/records/users_audit", // Set the URL for your JSON data
ajaxConfig:"GET", ajaxConfig:"GET",