mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-04 10:14:44 +02:00
Added possibility to show backup codes in user settings.
This commit is contained in:
parent
fba5f9794f
commit
604ebe420d
13 changed files with 288 additions and 6 deletions
|
@ -1,3 +1,5 @@
|
|||
{# @var user \App\Entity\UserSystem\User #}
|
||||
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<i class="fa fa-shield-alt fa-fw" aria-hidden="true"></i>
|
||||
|
@ -19,6 +21,10 @@
|
|||
<div class="tab-pane fade show active" id="tfa-google" role="tabpanel" aria-labelledby="google-tab">
|
||||
{{ form_start(google_form) }}
|
||||
{% if not tfa_google.enabled %}
|
||||
<div class="offset-3">
|
||||
<h6>{% trans %}tfa_google.disabled_message{% endtrans %}</h6>
|
||||
</div>
|
||||
|
||||
<div class="offset-3 row">
|
||||
<div class="col-3">
|
||||
<canvas class="qrcode" data-content="{{ tfa_google.qrContent }}"></canvas>
|
||||
|
@ -50,13 +56,33 @@
|
|||
|
||||
{{ form_row(google_form.google_confirmation) }}
|
||||
{% else %}
|
||||
Google Authenticator is enabled! TODO
|
||||
<div class="offset-3">
|
||||
<h6>{% trans %}tfa_google.enabled_message{% endtrans %}</h6>
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ form_row(google_form.submit) }}
|
||||
{{ form_end(google_form) }}
|
||||
</div>
|
||||
<div class="tab-pane fade" id="tfa-backup" role="tabpanel" aria-labelledby="backup-tab">
|
||||
{% if user.backupCodes is empty %}
|
||||
<div class="offset-3">
|
||||
<h6>{% trans %}tfa_backup.disabled{% endtrans %}</h6>
|
||||
<span>{% trans %}tfa_backup.explanation{% endtrans %}</span>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="offset-3">
|
||||
<h6>{% trans %}tfa_backup.enabled{% endtrans %}</h6>
|
||||
<span>{% trans %}tfa_backup.explanation{% endtrans %}</span>
|
||||
</div>
|
||||
<div class="offset-3 mt-2">
|
||||
<p class="mb-0"><b>{% trans %}tfa_backup.remaining_tokens{% endtrans %}:</b> {{ user.backupCodes | length }}</p>
|
||||
<p><b>{% trans %}tfa_backup.generation_date{% endtrans %}:</b> {{ user.backupCodesGenerationDate | format_datetime }}</p>
|
||||
</div>
|
||||
<div class="offset-3">
|
||||
<a href="{{ url('show_backup_codes') }}" target="_blank" data-no-ajax class="btn btn-primary">{% trans %}tfa_backup.show_codes{% endtrans %}</a>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
40
templates/Users/backup_codes.html.twig
Normal file
40
templates/Users/backup_codes.html.twig
Normal file
|
@ -0,0 +1,40 @@
|
|||
{% extends "base.html.twig" %}
|
||||
|
||||
{% block title %}{{ partdb_title }} {% trans %}tfa_backup.codes.title{% endtrans %}{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
{{ partdb_title }} {% trans %}tfa_backup.codes.title{% endtrans %}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{% trans %}tfa_backup.codes.explanation{% endtrans %}</h5>
|
||||
<p class="card-text">{% trans %}tfa_backup.codes.help{% endtrans %}</p>
|
||||
|
||||
<p class="mb-0"><b>{% trans %}tfa_backup.remaining_tokens{% endtrans %}:</b> {{ user.backupCodes | length }}</p>
|
||||
<p class="mb-0"><b>{% trans %}tfa_backup.username{% endtrans %}:</b> {{ user.name }}</p>
|
||||
<p><b>{% trans %}tfa_backup.generation_date{% endtrans %}:</b> {{ user.backupCodesGenerationDate | format_datetime }}</p>
|
||||
|
||||
<div class="alert border-dark">
|
||||
<div class="card-body">
|
||||
<ul class="row list-unstyled" id="backup_codes_list">
|
||||
{% for code in user.backupCodes %}
|
||||
<h4 class="col-6"><li><i class="far fa-square fa-fw"></i><span class="text-monospace text-dark ml-1">{{ code }}</span></li></h4>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p><small>{% trans with {'%date%': "now" | format_datetime} %}tfa_backup.codes.page_generated_on{% endtrans %}</small></p>
|
||||
|
||||
<a href="javascript:window.print()" class="btn btn-outline-dark d-print-none">
|
||||
<i class="fas fa-print fa-fw"></i> {% trans %}tfa_backup.codes.print{% endtrans %}
|
||||
</a>
|
||||
<button class="btn btn-outline-dark d-print-none" data-clipboard-text="{{ user.backupCodes | join('\n') }}">
|
||||
<i class="fas fa-copy"></i> {% trans %}tfa_backup.codes.copy_clipboard{% endtrans %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue