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

Proposed by David Owen
Status: Merged
Merged at revision: 64
Proposed branch: lp:~canonical-isd-hackers/canonical-identity-provider/cookie_next_param
Merge into: lp:canonical-identity-provider/release
Diff against target: 57 lines (+8/-6)
3 files modified
identityprovider/decorators.py (+4/-3)
identityprovider/urls.py (+1/-1)
identityprovider/views/account.py (+3/-2)
To merge this branch: bzr merge lp:~canonical-isd-hackers/canonical-identity-provider/cookie_next_param
Reviewer Review Type Date Requested Status
Anthony Lenton (community) Approve
Review via email: mp+27758@code.launchpad.net

Description of the change

Changed the next-path during cookie test to be a param, not embedded in the path. Should fix a problem encountered on the cloud deploy.

Also, this style matches what we do nearly everywhere else. Note the set_language view for an example.

To post a comment you must log in.
Revision history for this message
Anthony Lenton (elachuni) wrote :

Good work.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'identityprovider/decorators.py'
2--- identityprovider/decorators.py 2010-05-26 21:01:00 +0000
3+++ identityprovider/decorators.py 2010-06-16 20:57:27 +0000
4@@ -6,10 +6,11 @@
5 from django.core.cache import cache
6 from django.conf import settings
7 from django.template.loader import render_to_string
8+from django.utils.http import urlencode
9+
10 from datetime import datetime, timedelta
11 import functools
12 from hashlib import sha1
13-import urllib
14
15
16 def guest_required(func):
17@@ -57,8 +58,8 @@
18 if disable_cookie_check or request.session.test_cookie_worked():
19 return func(request, *args, **kwargs)
20 request.session.set_test_cookie()
21- quoted = urllib.quote_plus(request.get_full_path())
22- return HttpResponseRedirect('/+cookie;' + quoted)
23+ quoted = urlencode({'next': request.get_full_path()})
24+ return HttpResponseRedirect('/+cookie?' + quoted)
25 return wrapper
26
27
28
29=== modified file 'identityprovider/urls.py'
30--- identityprovider/urls.py 2010-05-24 21:54:05 +0000
31+++ identityprovider/urls.py 2010-06-16 20:57:27 +0000
32@@ -45,7 +45,7 @@
33 urlpatterns += patterns('identityprovider.views.account',
34 (r'^%(optional_token)s\+edit$' % repls, 'index'),
35 (r'^$', 'index'),
36- (r'^\+cookie;(?P<url>.+)$', 'cookie'),
37+ (r'^\+cookie$', 'cookie'),
38 (r'^%(optional_token)s\+index$' % repls, 'index'),
39 (r'^%(optional_token)s\+new-email$' % repls, 'new_email'),
40 (r'^%(optional_token)s\+verify-email$' % repls, 'verify_email'),
41
42=== modified file 'identityprovider/views/account.py'
43--- identityprovider/views/account.py 2010-06-01 20:32:17 +0000
44+++ identityprovider/views/account.py 2010-06-16 20:57:27 +0000
45@@ -35,9 +35,10 @@
46 return resp
47
48
49-def cookie(request, url=None):
50+def cookie(request):
51+ next = request.REQUEST.get('next', '/')
52 if request.session.test_cookie_worked():
53- return HttpResponseRedirect(url or '/')
54+ return HttpResponseRedirect(next)
55 # Send the cookie again, so that the user can hit reload on the
56 # page we return to continue on.
57 request.session.set_test_cookie()