launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #20516
[Merge] lp:~cjwatson/launchpad/fix-login-discharge-macaroon into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/fix-login-discharge-macaroon into lp:launchpad.
Commit message:
Fix the OpenID callback view to actually work properly when receiving a discharge macaroon.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/fix-login-discharge-macaroon/+merge/295925
Fix the OpenID callback view to actually work properly when receiving a discharge macaroon.
It was lacking a submit button, and the JS code to auto-submit it wasn't hooked up quite right. I've done a straight-through test with this on dogfood.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/fix-login-discharge-macaroon into lp:launchpad.
=== modified file 'lib/lp/services/webapp/templates/login-discharge-macaroon.pt'
--- lib/lp/services/webapp/templates/login-discharge-macaroon.pt 2016-05-19 02:02:39 +0000
+++ lib/lp/services/webapp/templates/login-discharge-macaroon.pt 2016-05-27 10:02:12 +0000
@@ -6,7 +6,23 @@
metal:use-macro="view/macro:page/main_only"
i18n:domain="launchpad">
- <body onload="document.forms[0].submit();">
+ <metal:block fill-slot="head_epilogue">
+ <script type="text/javascript"
+ tal:content="structure string:
+ LPJS.use('event', function(Y) {
+ Y.on('load', function(e) {
+ var form = document.getElementById('discharge-form');
+ var elements = form.elements;
+ for (var i = 0; i < elements.length; i++) {
+ elements[i].style.display = 'none';
+ }
+ form.submit();
+ });
+ });">
+ </script>
+ </metal:block>
+
+ <body>
<div class="top-portlet" metal:fill-slot="main">
<h1>OpenID transaction in progress</h1>
@@ -15,22 +31,18 @@
method="post"
enctype="application/x-www-form-urlencoded"
accept-charset="UTF-8">
- <input type="hidden"
- tal:condition="view/params/discharge_macaroon_action"
- tal:attributes="name view/params/discharge_macaroon_action"
- value="1" />
- <input type="hidden"
- tal:attributes="name view/params/discharge_macaroon_field;
- value view/discharge_macaroon_raw" />
+ <div class="actions">
+ <input type="hidden"
+ tal:condition="view/params/discharge_macaroon_action"
+ tal:attributes="name view/params/discharge_macaroon_action"
+ value="1" />
+ <input type="hidden"
+ tal:attributes="name view/params/discharge_macaroon_field;
+ value view/discharge_macaroon_raw" />
+ <input type="submit" value="Continue" />
+ </div>
</form>
</div>
-
- <script>
- var elements = document.forms[0].elements;
- for (var i = 0; i < elements.length; i++) {
- elements[i].style.display = "none";
- }
- </script>
</body>
</html>
=== modified file 'lib/lp/services/webapp/tests/test_login.py'
--- lib/lp/services/webapp/tests/test_login.py 2016-05-19 02:02:39 +0000
+++ lib/lp/services/webapp/tests/test_login.py 2016-05-27 10:02:12 +0000
@@ -512,13 +512,19 @@
[dict(tag.attrs) for tag in discharge_form.findAll('input')],
MatchesListwise([
ContainsDict({
+ 'type': Equals('hidden'),
'name': Equals('field.actions.complete'),
'value': Equals('1'),
}),
ContainsDict({
+ 'type': Equals('hidden'),
'name': Equals('field.discharge_macaroon'),
'value': Equals('dummy discharge'),
}),
+ ContainsDict({
+ 'type': Equals('submit'),
+ 'value': Equals('Continue'),
+ }),
]))
def test_discharge_macaroon_missing(self):
Follow ups