-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add resend email confirmation flow. (#368)
- Loading branch information
1 parent
123929b
commit eea7e73
Showing
8 changed files
with
72 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from __future__ import annotations | ||
|
||
from django.core import mail | ||
from django.test import Client | ||
from django.test import TestCase | ||
from django.urls import reverse | ||
|
||
from accounts.factories import UserFactory | ||
|
||
|
||
class ResendConfirmationEmailViewTests(TestCase): | ||
def setUp(self): | ||
self.client = Client() | ||
|
||
@classmethod | ||
def setUpTestData(cls): | ||
cls.user = UserFactory.create() | ||
cls.resend_confirmation_email_url = reverse("resend_email_confirmation") | ||
|
||
def test_must_be_authentication(self): | ||
response = self.client.post(self.resend_confirmation_email_url, {}, follow=True) | ||
self.assertRedirects( | ||
response, | ||
f"{reverse('login')}?next={self.resend_confirmation_email_url}", | ||
) | ||
|
||
def test_get_update_email_subscription_url(self): | ||
self.client.force_login(self.user) | ||
response = self.client.post(self.resend_confirmation_email_url, {}, follow=True) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertContains(response, "Profile Info") | ||
self.assertContains(response, "A verification email has been sent") | ||
self.assertEqual(len(mail.outbox), 1) | ||
self.assertEqual(mail.outbox[0].subject, "Djangonaut Space Email Confirmation") | ||
self.assertIn( | ||
"Thank you for signing up to Djangonaut Space! Click the link to verify your email:", | ||
mail.outbox[0].body, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{% if request.user.is_authenticated and not request.user.profile.email_confirmed %} | ||
<div class="my-2 mx-2 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded" role="alert"> | ||
<div class="my-2 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded inline-block w-full" role="alert"> | ||
<strong class="font-bold">Your email is not confirmed!</strong> | ||
<span class="block sm:inline">You may not be able to apply for sessions without <a href="{% url 'profile' %}" class="underline">confirming your email address.</a></span> | ||
{% include 'includes/resend_confirmation_email_button.html' %} | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,12 @@ | ||
{% if messages %} | ||
{% for message in messages %} | ||
<div class="messages alert-dismisible alert fade show text-center | ||
{% if 'error' in message.tags %} | ||
alert-danger | ||
{% elif 'warning' in message.tags %} | ||
alert-warning | ||
{% elif 'success' in message.tags %} | ||
alert-success | ||
{% else %} | ||
alert-info | ||
{% endif %} | ||
"> | ||
<div class="my-2 mx-2 px-4 py-3 rounded relative border | ||
{% if 'error' in message.tags %}bg-red-100 border-red-400 text-red-700 | ||
{% elif 'warning' in message.tags %}bg-orange-100 border-orange-400 text-orange-700 | ||
{% elif 'success' in message.tags %}bg-green-100 border-green-500 text-green-700 | ||
{% else %}bg-blue-100 border-blue-500 text-blue-700{% endif %}" | ||
role="alert"> | ||
<div class="{{ message.tags }}">{{ message}}</div> | ||
<!-- <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | ||
<span aria-hidden="true">×</span> | ||
</button> --> | ||
</div> | ||
{% endfor %} | ||
{% endif %} |
5 changes: 5 additions & 0 deletions
5
indymeet/templates/includes/resend_confirmation_email_button.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% load i18n %} | ||
<form action="{% url 'resend_email_confirmation' %}" method="POST" class="inline-block sm:ml-4 sm:float-right"> | ||
{% csrf_token %} | ||
<button type="submit">{% translate "Resend Email" %}</button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters