mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Save the date when a webauthn key was used last time for 2 factor authentication and show it in user settings
This commit is contained in:
parent
b886c0aeae
commit
db72dac243
5 changed files with 125 additions and 12 deletions
|
@ -230,4 +230,12 @@
|
|||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endmacro parameters_table %}
|
||||
{% endmacro parameters_table %}
|
||||
|
||||
{% macro format_date_nullable(datetime) %}
|
||||
{% if datetime is null %}
|
||||
<i>{% trans %}datetime.never{% endtrans %}</i>
|
||||
{% else %}
|
||||
{{ datetime|format_datetime }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
|
@ -1,5 +1,7 @@
|
|||
{# @var user \App\Entity\UserSystem\User #}
|
||||
|
||||
{% import "helper.twig" as helper %}
|
||||
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<i class="fa fa-shield-alt fa-fw" aria-hidden="true"></i>
|
||||
|
@ -124,6 +126,7 @@
|
|||
<th>#</th>
|
||||
<th>{% trans %}tfa_u2f.keys.name{% endtrans %}</th>
|
||||
<th>{% trans %}tfa_u2f.keys.added_date{% endtrans %}</th>
|
||||
<th>{% trans %}api_tokens.last_time_used{% endtrans %}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -133,6 +136,7 @@
|
|||
<td>{{ loop.index }} <b>(U2F)</b></td>
|
||||
<td>{{ key.name }}</td>
|
||||
<td>{{ key.addedDate | format_datetime }}</td>
|
||||
<td></td> {# For legacy keys no last time use date is saved #}
|
||||
<td><button type="submit" class="btn btn-danger btn-sm" name="key_id" value="{{ key.id }}"><i class="fas fa-trash-alt fa-fw"></i> {% trans %}tfa_u2f.key_delete{% endtrans %}</button></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -141,6 +145,7 @@
|
|||
<td>{{ loop.index }} <b>(WebAuthn)</b></td>
|
||||
<td>{{ key.name }}</td>
|
||||
<td>{{ key.addedDate | format_datetime }}</td>
|
||||
<td>{{ helper.format_date_nullable(key.lastTimeUsed) }}</td>
|
||||
<td><button type="submit" class="btn btn-danger btn-sm" name="webauthn_key_id" value="{{ key.id }}"><i class="fas fa-trash-alt fa-fw"></i> {% trans %}tfa_u2f.key_delete{% endtrans %}</button></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
{# @var user \App\Entity\UserSystem\User #}
|
||||
|
||||
{% macro format_date(datetime) %}
|
||||
{% if datetime is null %}
|
||||
<i>{% trans %}datetime.never{% endtrans %}</i>
|
||||
{% else %}
|
||||
{{ datetime|format_datetime }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
{% import "helper.twig" as helper %}
|
||||
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
|
@ -48,15 +42,15 @@
|
|||
<small class="text-muted">{% trans%}api_token.ends_with{% endtrans%} ...<i>{{ api_token.lastTokenChars }}</i></small></td>
|
||||
<td>{{ api_token.level.translationKey|trans }}</td>
|
||||
<td>
|
||||
{{ _self.format_date(api_token.validUntil) }}
|
||||
{{ helper.format_date_nullable(api_token.validUntil) }}
|
||||
{% if api_token.valid %}
|
||||
<span class="badge bg-success badge-success">{% trans %}api_token.valid{% endtrans %}</span>
|
||||
{% else %}
|
||||
<span class="badge bg-warning badge-warning">{% trans %}api_token.expired{% endtrans %}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ _self.format_date(api_token.addedDate) }}</td>
|
||||
<td>{{ _self.format_date(api_token.lastTimeUsed) }}</td>
|
||||
<td>{{ helper.format_date_nullable(api_token.addedDate) }}</td>
|
||||
<td>{{ helper.format_date_nullable(api_token.lastTimeUsed) }}</td>
|
||||
<td>
|
||||
<button type="submit" class="btn btn-danger btn-sm" name="token_id"
|
||||
value="{{ api_token.id }}" {% if not is_granted('@api.manage_tokens') %}disabled="disabled"{% endif %}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue