Merge lp:~canonical-isd-hackers/canonical-identity-provider/bug_528389_new_account_conf into lp:canonical-identity-provider/release

Proposed by Danny Tamez
Status: Merged
Merged at revision: 15
Proposed branch: lp:~canonical-isd-hackers/canonical-identity-provider/bug_528389_new_account_conf
Merge into: lp:canonical-identity-provider/release
Diff against target: 90 lines (+39/-1)
4 files modified
identityprovider/templates/registration/logout_to_confirm.html (+15/-0)
identityprovider/tests/test_views_ui.py (+19/-0)
identityprovider/urls.py (+1/-0)
identityprovider/views/ui.py (+4/-1)
To merge this branch: bzr merge lp:~canonical-isd-hackers/canonical-identity-provider/bug_528389_new_account_conf
Reviewer Review Type Date Requested Status
Łukasz Czyżykowski (community) Approve
Stuart Metcalfe (community) Needs Fixing
Review via email: mp+25034@code.launchpad.net

Description of the change

When a user attempts to confirm a token to create a new account if they are already logged in they will now receive a polite error message instead of the app silently failing.

To post a comment you must log in.
Revision history for this message
Stuart Metcalfe (stuartmetcalfe) wrote :

Typos in identityprovider/templates/registration/logout_to_confirm.html:

 * {% block "title" %}{% trans "Can not cofirm token while logged in" %}{% endblock %}
   should be:
   {% block "title" %}{% trans "Can not confirm token while logged in" %}{% endblock %}

 * <p>{% blocktrans %}You can not confrim this token because you are logged in as
   should be:
   <p>{% blocktrans %}You can not confirm this token because you are logged in as

review: Needs Fixing
Revision history for this message
Łukasz Czyżykowski (lukasz-czyzykowski) wrote :

All OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'identityprovider/templates/registration/logout_to_confirm.html'
2--- identityprovider/templates/registration/logout_to_confirm.html 1970-01-01 00:00:00 +0000
3+++ identityprovider/templates/registration/logout_to_confirm.html 2010-05-11 13:11:25 +0000
4@@ -0,0 +1,15 @@
5+<!-- Copyright 2010 Canonical Ltd. This software is licensed under the
6+GNU Affero General Public License version 3 (see the file LICENSE). -->
7+
8+{% extends "base.html" %}
9+{% load i18n %}
10+
11+{% block "title" %}{% trans "Can not confirm token while logged in" %}{% endblock %}
12+
13+{% block "content" %}
14+ <h1 class="main">{% trans "Can not confirm token while logged in" %}</h1>
15+
16+ <p>{% blocktrans %}You can not confirm this token because you are logged in as
17+ a different user. Please log out and try again.{% endblocktrans %}</p>
18+{% endblock %}
19+
20
21=== modified file 'identityprovider/tests/test_views_ui.py'
22--- identityprovider/tests/test_views_ui.py 2010-05-10 16:59:23 +0000
23+++ identityprovider/tests/test_views_ui.py 2010-05-11 13:11:25 +0000
24@@ -205,10 +205,29 @@
25
26 def test_confirm_account_with_bad_token(self):
27 token = self.create_token(at.LoginTokenType.NEWPERSONLESSACCOUNT)
28+ self.authenticate()
29+ r = self.client.get('/+logout')
30
31 r = self.client.get('/token/%s/+newaccount' % token.token)
32 self.assertRedirects(r, '/+bad-token')
33
34+ def test_logout_to_confirm(self):
35+ r = self.client.get('/+logout-to-confirm')
36+ self.assertEquals(r.status_code, 200)
37+
38+ def test_confirm_account_while_logged_in(self):
39+ token = self.create_token(at.LoginTokenType.NEWPERSONLESSACCOUNT)
40+ self.authenticate()
41+ r = self.client.get('/token/%s/' % token.token)
42+ location = None
43+ for item in r.items():
44+ if item[0] == 'Location':
45+ location = item[1]
46+ break
47+ location = location[len('http://testserver'):]
48+ r = self.client.get(location)
49+ self.assertRedirects(r, '/+logout-to-confirm')
50+
51 def test_forgot_password_when_captcha_verification_fails(self):
52 r = self.request_when_captcha_fails('/+forgot_password',
53 {'email': 'mark@example.com'})
54
55=== modified file 'identityprovider/urls.py'
56--- identityprovider/urls.py 2010-05-04 13:30:27 +0000
57+++ identityprovider/urls.py 2010-05-11 13:11:25 +0000
58@@ -35,6 +35,7 @@
59 'confirm_account'),
60 (r'^token/(?P<authtoken>[A-Za-z0-9]{20})/\+newemail$', 'confirm_email'),
61 (r'^\+bad-token', 'bad_token'),
62+ (r'^\+logout-to-confirm', 'logout_to_confirm'),
63 (r'^%(optional_token)s\+email-sent$' % repls, 'email_sent'),
64 (r'^debug-token/(?P<email>.*\@.*\..*)$', 'token_from_email'),
65 (r'^\+deactivated$', 'deactivated'),
66
67=== modified file 'identityprovider/views/ui.py'
68--- identityprovider/views/ui.py 2010-05-05 13:11:46 +0000
69+++ identityprovider/views/ui.py 2010-05-11 13:11:25 +0000
70@@ -204,9 +204,10 @@
71 return None
72
73
74-@guest_required
75 @check_readonly
76 def confirm_account(request, authtoken):
77+ if request.user.is_authenticated():
78+ return HttpResponseRedirect('/+logout-to-confirm')
79 atrequest = get_object_or_404(AuthToken, token=authtoken,
80 token_type=LoginTokenType.NEWPERSONLESSACCOUNT)
81 session_token = request.session.get('token_newaccount')
82@@ -299,6 +300,8 @@
83 })
84 return render_to_response('registration/bad_token.html', context)
85
86+def logout_to_confirm(request):
87+ return render_to_response('registration/logout_to_confirm.html')
88
89 def deactivated(request):
90 context = RequestContext(request, {