Skip to content

Commit df9e4ed

Browse files
author
Kevin Turner
committed
[project @ examples/consumer: add an /affiliate page to help exercise myopenid's affiliate code]
1 parent df427f0 commit df9e4ed

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

examples/consumer.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ def quoteattr(s):
4343

4444
SREG_URI = 'http://openid.net/sreg/1.0'
4545

46+
# Used with an OpenID provider affiliate program.
47+
OPENID_PROVIDER_NAME = 'MyOpenID'
48+
OPENID_PROVIDER_URL ='https://www.myopenid.com/affiliate_signup?affiliate_id=39'
49+
4650

4751
class OpenIDHTTPServer(HTTPServer):
4852
"""http server that contains a reference to an OpenID consumer and
@@ -132,6 +136,8 @@ def do_GET(self):
132136
self.doVerify()
133137
elif path == '/process':
134138
self.doProcess()
139+
elif path == '/affiliate':
140+
self.doAffiliate()
135141
else:
136142
self.notFound()
137143

@@ -246,6 +252,19 @@ def doProcess(self):
246252

247253
self.render(message, css_class, info.identity_url, sreg_data=sreg)
248254

255+
def doAffiliate(self):
256+
"""Direct the user sign up with an affiliate OpenID provider."""
257+
sreg_required = ['nickname']
258+
sreg_optional = ['fullname', 'email']
259+
href = '%s&openid.sreg.required=%s&openid.sreg.optional=%s' % (
260+
OPENID_PROVIDER_URL,
261+
','.join(sreg_required),
262+
','.join(sreg_optional),
263+
)
264+
message = """Get an OpenID at <a href=%s>%s</a>""" % (
265+
quoteattr(href), OPENID_PROVIDER_NAME)
266+
self.render(message)
267+
249268
def renderSREG(self, sreg_data):
250269
if not sreg_data:
251270
self.wfile.write(

0 commit comments

Comments
 (0)