diff --git a/hc/accounts/migrations/0034_credential.py b/hc/accounts/migrations/0034_credential.py index b3167f58..2c67619e 100644 --- a/hc/accounts/migrations/0034_credential.py +++ b/hc/accounts/migrations/0034_credential.py @@ -1,4 +1,4 @@ -# Generated by Django 3.1.2 on 2020-11-12 13:39 +# Generated by Django 3.1.2 on 2020-11-12 15:29 from django.conf import settings from django.db import migrations, models @@ -20,8 +20,9 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('code', models.UUIDField(default=uuid.uuid4, unique=True)), ('name', models.CharField(blank=True, max_length=200)), + ('created', models.DateTimeField(auto_now_add=True)), ('data', models.BinaryField()), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='credentials', to=settings.AUTH_USER_MODEL)), ], ), ] diff --git a/hc/accounts/models.py b/hc/accounts/models.py index 939fb1b1..4ae69de9 100644 --- a/hc/accounts/models.py +++ b/hc/accounts/models.py @@ -397,6 +397,7 @@ class Credential(models.Model): code = models.UUIDField(default=uuid.uuid4, unique=True) name = models.CharField(max_length=200, blank=True) user = models.ForeignKey(User, models.CASCADE, related_name="credentials") + created = models.DateTimeField(auto_now_add=True) data = models.BinaryField() def unpack(self): diff --git a/static/css/profile.css b/static/css/profile.css index 9c0fd4d9..3268e29a 100644 --- a/static/css/profile.css +++ b/static/css/profile.css @@ -62,3 +62,6 @@ span.loading { text-overflow: ellipsis; } +#my-keys th { + border-top: 0; +} diff --git a/templates/accounts/profile.html b/templates/accounts/profile.html index 065257a7..91e0b0c4 100644 --- a/templates/accounts/profile.html +++ b/templates/accounts/profile.html @@ -63,26 +63,34 @@
{% csrf_token %} -

Two Factor Authentication

+

Two-factor Authentication

{% if profile.user.credentials.exists %} - +
+ + + {% for credential in profile.user.credentials.all %} - - + + {% endfor %}
Security keys
{{ credential.code }}{{ credential.name|default:"unnamed" }} + {{ credential.name|default:"unnamed" }} + – registered on {{ credential.created|date:"M j, Y" }} + Remove
{% else %}

- Your account has no registered two factor authentication - methods. + Your account has no registered security keys. + Two-factor authentication is disabled.

{% endif %} Add 2FA Credential + class="btn btn-default pull-right"> + Register New Security Key +