Skip to content

Commit

Permalink
add column '2fa status' for customers and admins
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kaufmann <[email protected]>
  • Loading branch information
d00p committed Jul 20, 2024
1 parent 2dae780 commit 4d3cf5d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Froxlor/UI/Callbacks/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public static function yesno(array $attributes): array
];
}

public static function type2fa(array $attributes): array
{
return [
'macro' => 'type2fa',
'data' => (int)$attributes['data']
];
}

public static function customerfullname(array $attributes): string
{
return User::getCorrectFullUserDetails($attributes['fields'], true);
Expand Down
6 changes: 6 additions & 0 deletions lib/tablelisting/admin/tablelisting.admins.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
'class' => 'text-center',
'callback' => [Text::class, 'boolean'],
],
'type_2fa' => [
'label' => lng('2fa.type_2fa'),
'field' => 'type_2fa',
'class' => 'text-center',
'callback' => [Text::class, 'type2fa'],
],
],
'visible_columns' => Listing::getVisibleColumnsForListing('admin_list', [
'loginname',
Expand Down
6 changes: 6 additions & 0 deletions lib/tablelisting/admin/tablelisting.customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@
'class' => 'text-center',
'callback' => [Text::class, 'boolean'],
],
'c.type_2fa' => [
'label' => lng('2fa.type_2fa'),
'field' => 'type_2fa',
'class' => 'text-center',
'callback' => [Text::class, 'type2fa'],
],
],
'visible_columns' => Listing::getVisibleColumnsForListing('customer_list', [
'c.name',
Expand Down
1 change: 1 addition & 0 deletions lng/de.lng.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
'2fa_ga_desc' => 'Das Konto ist eingerichtet, um zeitbasierte Einmalpasswörter via Authenticator-App zu erhalten. Um die gewünschte Authenticator-App einzurichten, scanne bitte den untenstehenden QR-Code. Zum Deaktivieren, klicke auf "2FA deaktivieren"',
'2fa_not_activated' => 'Zwei-Faktor Authentifizierung ist nicht aktiviert',
'2fa_not_activated_for_user' => 'Zwei-Faktor Authentifizierung ist für den aktuellen Benutzer nicht aktiviert',
'type_2fa' => '2FA Status',
],
'admin' => [
'overview' => 'Übersicht',
Expand Down
1 change: 1 addition & 0 deletions lng/en.lng.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
'2fa_ga_desc' => 'Your account is set up to use time-based one-time passwords via authenticator-app. Please scan the QR code below with your desired authenticator app to generate the codes. To deactivate, click on "Deactivate 2FA"',
'2fa_not_activated' => 'Two-factor authentication is not enabled',
'2fa_not_activated_for_user' => 'Two-factor authentication is not enabled for the current user',
'type_2fa' => '2FA status',
],
'admin' => [
'overview' => 'Overview',
Expand Down
10 changes: 10 additions & 0 deletions templates/Froxlor/table/macros.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
{% endif %}
{% endmacro %}

{% macro type2fa(data) %}
{% if (data == 1) %}
<i class="fa-solid fa-envelope text-success"></i>
{% elseif (data == 2) %}
<i class="fa-solid fa-mobile text-success"></i>
{% else %}
<i class="fa-solid fa-lock-open text-warning"></i>
{% endif %}
{% endmacro %}

{% macro link(data) %}
{% apply spaceless %}
<a href="{{ data.href }}" {% if data.class is defined %} class="{{ data.class }}" {% endif %} {% if data.target is defined %} target="{{ data.target }}" {% endif %} {% if data.title is defined %} title="{{ data.title }}" {% endif %}>
Expand Down
2 changes: 2 additions & 0 deletions templates/Froxlor/table/table.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
{{ macros.domainWithSan(td.data.data) }}
{% elseif td.data.macro == 'actions' %}
{{ macros.actions(td.data.data) }}
{% elseif td.data.macro == 'type2fa' %}
{{ macros.type2fa(td.data.data) }}
{% else %}
Table macro '{{ td.data.macro|json_encode }}' is not implemented!
Unable to handle this data: {{ td.data|json_encode }}
Expand Down

0 comments on commit 4d3cf5d

Please sign in to comment.