Skip to content

Commit 9e2b54c

Browse files
author
tailor
committed
[project @ Replace redirect with autoSubmit form in example]
1 parent ec7835c commit 9e2b54c

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎examples/consumer.py‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,10 @@ def doVerify(self):
185185

186186
trust_root = self.server.base_url
187187
return_to = self.buildURL('process')
188-
redirect_url = request.redirectURL(trust_root, return_to)
188+
form_html = request.formMarkup(trust_root, return_to,
189+
form_tag_attrs={'id':'openid_message'})
189190

190-
self.redirect(redirect_url)
191+
self.autoSubmit(form_html, 'openid_message')
191192

192193
def requestRegistrationData(self, request):
193194
required = ','.join(['nickname'])
@@ -288,15 +289,14 @@ def buildURL(self, action, **query):
288289
base = urlparse.urljoin(self.server.base_url, action)
289290
return appendArgs(base, query)
290291

291-
def redirect(self, redirect_url):
292-
"""Send a redirect response to the given URL to the browser."""
292+
def autoSubmit(self, form, id):
293+
"""Send a page containing an auto-submitting form."""
293294
response = """\
294-
Location: %s
295-
Content-type: text/plain
296-
297-
Redirecting to %s""" % (redirect_url, redirect_url)
298-
self.send_response(302)
299-
self.setSessionCookie()
295+
<html><head><title>OpenID transaction in progress</title></head>
296+
<body onload='document.getElementById("%s").submit()'>
297+
%s
298+
</body></html>
299+
"""%(id, form)
300300
self.wfile.write(response)
301301

302302
def notFound(self):

0 commit comments

Comments
 (0)