diff --git a/cp/app/Controllers/ProfileController.php b/cp/app/Controllers/ProfileController.php index c526178..eb62989 100644 --- a/cp/app/Controllers/ProfileController.php +++ b/cp/app/Controllers/ProfileController.php @@ -68,12 +68,14 @@ class ProfileController extends Controller 'SELECT * FROM users_webauthn WHERE user_id = ? ORDER BY created_at DESC LIMIT 5', [$userId] ); + $isWebAuthnEnabled = (envi('WEB_AUTHN_ENABLED') === 'true') ? true : false; + 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]); } 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]); } 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]); } } diff --git a/cp/resources/views/admin/profile/profile.twig b/cp/resources/views/admin/profile/profile.twig index 813d1f5..6eb450b 100644 --- a/cp/resources/views/admin/profile/profile.twig +++ b/cp/resources/views/admin/profile/profile.twig @@ -177,11 +177,25 @@ {% else %} + {% if isWebaEnabled %}

{{ __('WebAuthn Authentication') }}

{{ __('Secure your account with WebAuthn. Click the button below to register your device for passwordless sign-in.') }}

+ {% else %} +
+

{{ __('WebAuthn Authentication') }}{{ __('Disabled') }}

+

{{ __('WebAuthn is currently disabled for this installation. To enable WebAuthn authentication, follow these steps:') }}

+
    +
  1. {{ __('Edit the environment configuration file located at:') }} /var/www/cp/.env
  2. +
  3. {{ __('Find or add the following line:') }}
  4. +
    WEB_AUTHN_ENABLED=true
    +
  5. {{ __('Save the changes and reload the server (Caddy) using the following command:') }}
  6. +
    sudo systemctl reload caddy
    +
+
+ {% endif %} {% endif %}
diff --git a/cp/resources/views/partials/js-profile.twig b/cp/resources/views/partials/js-profile.twig index 0f26134..021c932 100644 --- a/cp/resources/views/partials/js-profile.twig +++ b/cp/resources/views/partials/js-profile.twig @@ -5,7 +5,7 @@ var table; document.addEventListener("DOMContentLoaded", function(){ - +{% if isWebaEnabled %} const connectButton = document.getElementById('connectWebAuthnButton'); connectButton.addEventListener('click', async function() { @@ -124,7 +124,7 @@ } return window.btoa(binary); } - +{% endif %} table = new Tabulator("#auditTable", { ajaxURL:"/api/records/users_audit", // Set the URL for your JSON data ajaxConfig:"GET",