Skip to content

Commit 9da66a5

Browse files
committed
[chores] Updated send email verification logic (django-allauth 65.11.x)
Disabled djangoa-alluth rate limiting during testing.
1 parent ea8ee1a commit 9da66a5

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

openwisp_radius/saml/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from urllib.parse import parse_qs, quote, urlencode, urlparse
33

44
import swapper
5+
from allauth.account.internal.flows import email_verification
56
from allauth.account.models import EmailAddress
6-
from allauth.account.utils import send_email_confirmation
77
from django import forms
88
from django.conf import settings
99
from django.contrib.auth import get_user_model, logout
@@ -148,7 +148,7 @@ def get_success_url(self):
148148

149149
def form_valid(self, form):
150150
user = form.save()
151-
send_email_confirmation(self.request, user, signup=True, email=user.email)
151+
email_verification.send_verification_email_for_user(self.request, user)
152152
return self.get_response()
153153

154154
def is_user_profile_complete(self):

openwisp_radius/tests/test_saml/test_views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ def test_user_has_email(self):
216216
def test_user_has_no_email(self):
217217
user = self._create_user()
218218
User.objects.filter(pk=user.pk).update(email="")
219+
user.emailaddress_set.all().delete()
220+
user.refresh_from_db()
219221
self.client.force_login(user)
220222
url = f"{self.view_path}?next=https://captive-portal.example.com/login/"
221223
response = self.client.get(url)

tests/openwisp2/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@
299299

300300
ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = "email_confirmation_success"
301301
ACCOUNT_EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL = "email_confirmation_success"
302+
# disable allauth ratelimiting during automated tests
303+
if TESTING:
304+
ACCOUNT_RATE_LIMITS = False
302305

303306
# OPENWISP_RADIUS_PASSWORD_RESET_URLS = {
304307
# # use the uuid because the slug can change

0 commit comments

Comments
 (0)