diff --git a/hc/accounts/views.py b/hc/accounts/views.py index fe77e900..724275c9 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -223,7 +223,7 @@ def profile(request): "2fa_status": "default", "added_credential_name": request.session.pop("added_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, } @@ -658,7 +658,7 @@ def remove_credential(request, code): credential.delete() 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) diff --git a/templates/accounts/add_credential.html b/templates/accounts/add_credential.html index 0e9230de..61353d02 100644 --- a/templates/accounts/add_credential.html +++ b/templates/accounts/add_credential.html @@ -3,7 +3,6 @@ {% block content %} -{{ registration_dict|json_script:"registration" }}
{% csrf_token %}

Two-factor Authentication

- {% if credentials.exists %} + {% if credentials %} @@ -87,10 +87,18 @@ {% endfor %}
+ {% if credentials|length == 1 %} +

+ Tip: add a second key! + It is a good practice to register at least two security keys + and store them separately. +

+ {% endif %} + {% else %}

Your account has no registered security keys.
- Two-factor authentication is disabled. + Two-factor authentication is not active.

{% endif %}

You are about to remove the security key {{ credential.name|default:'unnamed' }} - from your two-factor authentication methods. Are you sure? + from your two-factor authentication methods.

+ + {% if is_last %} +

+ After removing this key, + two-factor authentication will no longer be active + for your {% site_name%} account. +

+ {% endif %} +