diff --git a/scipost_django/profiles/models.py b/scipost_django/profiles/models.py index 7fd86184d388fe38d1143cfa869447c5b2202e76..bbfa877a959b8ebd15e6a8b0cfaf7de95455c4d9 100644 --- a/scipost_django/profiles/models.py +++ b/scipost_django/profiles/models.py @@ -272,6 +272,7 @@ class ProfileEmail(models.Model): return self.email def reset_verification_token(self): + self.verified = False self.verification_token = secrets.token_urlsafe(40) self.token_expiration = timezone.now() + datetime.timedelta(hours=48) self.save() diff --git a/scipost_django/profiles/templates/profiles/_hx_profile_emails_table_row.html b/scipost_django/profiles/templates/profiles/_hx_profile_emails_table_row.html index c46368de1c8add46e600aeef7d8cd3b2d7ff942f..b750d7580e41c7d816972e8fff5f5c5d8f5e7110 100644 --- a/scipost_django/profiles/templates/profiles/_hx_profile_emails_table_row.html +++ b/scipost_django/profiles/templates/profiles/_hx_profile_emails_table_row.html @@ -18,8 +18,10 @@ </td> <td> - {% if profile_mail.verified %} + {% if profile_mail.verified and profile_mail.verification_token %} <span class="text-success">{% include "bi/check-circle-fill.html" %}</span> + {% elif profile_mail.verified and not profile_mail.verification_token %} + <span class="text-warning">{% include "bi/question-circle-fill.html" %}</span> {% elif not profile_mail.has_token_expired %} <span class="text-warning">{% include "bi/clock-fill.html" %}</span> {% else %} @@ -56,7 +58,7 @@ {% if not profile_mail.has_token_expired %}hx-confirm="Your previous verification code has not expired yet. Are you sure you want to resend the verification email?"{% endif %} hx-confirm="This will send a verification email to the address. Are you sure?" hx-patch="{% url 'profiles:_hx_profile_email_request_verification' profile_mail.id %}" - {% if profile_mail.verified %}disabled{% endif %} + {% if profile_mail.verified and profile_mail.verification_token %}disabled{% endif %} >Verify</button> {% endif %} diff --git a/scipost_django/profiles/views.py b/scipost_django/profiles/views.py index 612aaaf565f07b064bccc54b18d4f009f8239cf4..d8158b7ca5bbf9566acd6a10fe63076db31784d1 100644 --- a/scipost_django/profiles/views.py +++ b/scipost_django/profiles/views.py @@ -595,7 +595,7 @@ def _hx_profile_email_request_verification(request, email_id): tag="danger", ) - if not profile_email.verified: + if not (profile_email.verified and profile_email.verification_token is not None): profile_email.send_verification_email() messages.success( request, diff --git a/scipost_django/templates/bi/clock-fill.html b/scipost_django/templates/bi/clock-fill.html index d9bdcd85bb99ed8bee3d8bc85fd5c27195b7cacb..d61df73cdc39e1c9b066b145f1bdb0c603ecc460 100644 --- a/scipost_django/templates/bi/clock-fill.html +++ b/scipost_django/templates/bi/clock-fill.html @@ -1,6 +1,6 @@ <svg xmlns="http://www.w3.org/2000/svg" - width="16" - height="16" + width="1em" + height="1em" fill="currentColor" class="bi bi-clock-fill" viewBox="0 0 16 16">