Browse Source

Add notes about adding a second key, and removing the last key

pull/456/head
Pēteris Caune 4 years ago
parent
commit
8448f882cf
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
4 changed files with 22 additions and 6 deletions
  1. +2
    -2
      hc/accounts/views.py
  2. +0
    -1
      templates/accounts/add_credential.html
  3. +10
    -2
      templates/accounts/profile.html
  4. +10
    -1
      templates/accounts/remove_credential.html

+ 2
- 2
hc/accounts/views.py View File

@ -223,7 +223,7 @@ def profile(request):
"2fa_status": "default", "2fa_status": "default",
"added_credential_name": request.session.pop("added_credential_name", ""), "added_credential_name": request.session.pop("added_credential_name", ""),
"removed_credential_name": request.session.pop("removed_credential_name", ""), "removed_credential_name": request.session.pop("removed_credential_name", ""),
"credentials": request.user.credentials.order_by("id"),
"credentials": list(request.user.credentials.order_by("id")),
"use_2fa": settings.RP_ID, "use_2fa": settings.RP_ID,
} }
@ -658,7 +658,7 @@ def remove_credential(request, code):
credential.delete() credential.delete()
return redirect("hc-profile") return redirect("hc-profile")
ctx = {"credential": credential}
ctx = {"credential": credential, "is_last": request.user.credentials.count() == 1}
return render(request, "accounts/remove_credential.html", ctx) return render(request, "accounts/remove_credential.html", ctx)


+ 0
- 1
templates/accounts/add_credential.html View File

@ -3,7 +3,6 @@
{% block content %} {% block content %}
{{ registration_dict|json_script:"registration" }}
<div class="row"> <div class="row">
<form <form
id="add-credential-form" id="add-credential-form"


+ 10
- 2
templates/accounts/profile.html View File

@ -68,7 +68,7 @@
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
<h2>Two-factor Authentication</h2> <h2>Two-factor Authentication</h2>
{% if credentials.exists %}
{% if credentials %}
<table id="my-keys" class="table"> <table id="my-keys" class="table">
<tr> <tr>
@ -87,10 +87,18 @@
{% endfor %} {% endfor %}
</table> </table>
{% if credentials|length == 1 %}
<p class="alert alert-info">
<strong>Tip: add a second key!</strong>
It is a good practice to register at least two security keys
and store them separately.
</p>
{% endif %}
{% else %} {% else %}
<p> <p>
Your account has no registered security keys.<br /> Your account has no registered security keys.<br />
Two-factor authentication is disabled.
Two-factor authentication is not active.
</p> </p>
{% endif %} {% endif %}
<a <a


+ 10
- 1
templates/accounts/remove_credential.html View File

@ -12,8 +12,17 @@
<p></p> <p></p>
<p>You are about to remove <p>You are about to remove
the security key <strong>{{ credential.name|default:'unnamed' }}</strong> the security key <strong>{{ credential.name|default:'unnamed' }}</strong>
from your two-factor authentication methods. Are you sure?
from your two-factor authentication methods.
</p> </p>
{% if is_last %}
<p>
After removing this key,
<strong>two-factor authentication will no longer be active</strong>
for your {% site_name%} account.
</p>
{% endif %}
<div class="text-right"> <div class="text-right">
<a <a
href="{% url 'hc-profile' %}" href="{% url 'hc-profile' %}"


Loading…
Cancel
Save