Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

openid project creatoin works now.

  • Loading branch information...
commit f65488ba8129646d82f03396acacfb46d85183e9 1 parent 1ab00b5
@bradfitz authored
Showing with 17 additions and 11 deletions.
  1. +8 −6 consumer.py
  2. +1 −1  login.html
  3. +7 −3 main.py
  4. +1 −1  models.py
View
14 consumer.py
@@ -73,7 +73,6 @@ class Session(db.Expando):
"""An in-progress OpenID login."""
claimed_id = db.StringProperty()
server_url = db.LinkProperty()
- store_and_display = db.BooleanProperty()
class Login(db.Model):
@@ -295,13 +294,13 @@ def get(self):
self.render()
-class LoginHandler(Handler):
+class StartHandler(Handler):
"""Handles a POST response to the OpenID login form."""
def post(self):
"""Handles login requests."""
logging.info(self.args_to_dict())
- openid_url = self.request.get('openid')
+ openid_url = self.request.get('openid_url')
if not openid_url:
self.report_error('Please enter an OpenID URL.')
return
@@ -321,7 +320,6 @@ def post(self):
self.session.claimed_id = auth_request.endpoint.claimed_id
self.session.server_url = auth_request.endpoint.server_url
- self.session.store_and_display = self.request.get('display', 'no') != 'no'
self.store_session()
sreg_request = sreg.SRegRequest(optional=['nickname', 'fullname', 'email'])
@@ -385,13 +383,17 @@ def get(self):
session=self.session.key())
login.put()
- self.render(locals())
+ self.response.headers.add_header('Set-Cookie',
+ 'session=%s; path=/' % session_id)
+
+ # TODO(bradfitz: redirect to proper 'next' URL
+ self.redirect('/')
# Map URLs to our RequestHandler subclasses above
_URLS = [
('/s/openid', FrontPage),
- ('/s/startopenid', LoginHandler),
+ ('/s/startopenid', StartHandler),
('/s/finish', FinishHandler),
]
View
2  login.html
@@ -11,7 +11,7 @@
<p>Choose your authentication mechanism:<p>
- <form method='/s/startopenid' method='POST'>
+ <form action='/s/startopenid' method='POST'>
<div style='margin: 2em 0 2em 0'>
<img src='/static/openid-logo2.png' width='112' height='36' alt='OpenID' align='absmiddle' /><br/>
<input type='text' name='openid_url' id='openid_url' size='40' />
View
10 main.py
@@ -25,6 +25,7 @@
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp import util
+import consumer
import models
@@ -36,9 +37,12 @@ def GetCurrentUser(request):
session_id = request.cookies.get('session', '')
if not session_id:
return None
- return models.User(openid_user=session_id) # hack
-
-
+ login = consumer.Login.get_by_key_name(session_id)
+ if not login:
+ return None
+ return models.User(openid_user=login.claimed_id)
+
+
class IndexHandler(webapp.RequestHandler):
def get(self):
View
2  models.py
@@ -52,7 +52,7 @@ def sha1_key(self):
if self.google_user:
return sha.sha(self.google_user.email() + SALT).hexdigest()[0:8]
if self.openid_user:
- return sha.sha(self.openid_user() + SALT).hexdigest()[0:8]
+ return sha.sha(self.openid_user + SALT).hexdigest()[0:8]
return Exception("unknown user type")
def GetOrCreateFromDatastore(self):
Please sign in to comment.
Something went wrong with that request. Please try again.