Skip to content

Commit 5bcf36e

Browse files
committed
Fix a couple of bugs in the account registration cleanup
- Legacy-Id: 11167
1 parent a99aa32 commit 5bcf36e

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

ietf/ietfauth/tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django.contrib.auth.models import User
99
from django.conf import settings
1010

11-
from ietf.utils.test_utils import TestCase, login_testing_unauthorized
11+
from ietf.utils.test_utils import TestCase, login_testing_unauthorized, unicontent
1212
from ietf.utils.test_data import make_test_data
1313
from ietf.utils.mail import outbox, empty_outbox
1414
from ietf.person.models import Person, Email
@@ -89,6 +89,7 @@ def test_create_account(self):
8989
empty_outbox()
9090
r = self.client.post(url, { 'email': email })
9191
self.assertEqual(r.status_code, 200)
92+
self.assertTrue("Account created" in unicontent(r.content))
9293
self.assertEqual(len(outbox), 1)
9394

9495
# go to confirm page

ietf/ietfauth/views.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def index(request):
8080
# return HttpResponseRedirect(redirect_to)
8181

8282
def create_account(request):
83-
success = False
83+
to_email = None
84+
8485
if request.method == 'POST':
8586
form = RegistrationForm(request.POST)
8687
if form.is_valid():
@@ -103,7 +104,7 @@ def create_account(request):
103104

104105
return render(request, 'registration/create.html', {
105106
'form': form,
106-
'success': success,
107+
'to_email': to_email,
107108
})
108109

109110
def confirm_account(request, auth):
@@ -140,10 +141,12 @@ def confirm_account(request, auth):
140141
name=email,
141142
ascii=email)
142143
if not email_obj:
143-
email_obj = Email.objects.create(address=email,
144-
person=person)
145-
email_obj.person = person
146-
email_obj.save()
144+
email_obj = Email.objects.create(address=email, person=person)
145+
else:
146+
if not email_obj.person:
147+
email_obj.person = person
148+
email_obj.save()
149+
147150
person.user = user
148151
person.save()
149152

@@ -315,6 +318,8 @@ def confirm_password_reset(request, auth):
315318
user.save()
316319
# password is also stored in htpasswd file
317320
save_htpasswd_file(user.username, password)
321+
322+
success = True
318323
else:
319324
form = PasswordForm()
320325

ietf/templates/registration/create.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
{% block content %}
1010
{% origin %}
1111

12-
{% if success %}
12+
{% if to_email %}
1313
<h1>Account created successfully</h1>
14+
1415
<p>Your account creation request has been successfully received.</p>
15-
<p>We have sent you an email with instructions on how to complete the process.</p>
16+
17+
<p>We have sent an email to {{ to_email }} with instructions on how to complete the process.</p>
1618

1719
{% else %}
1820
<div class="row">

0 commit comments

Comments
 (0)