X-Git-Url: http://git.veekun.com/zzz-floof.git/blobdiff_plain/224a257ade788e1a87aab78032dc3cdc9677cc06..f4a6882d2cdb1baeb2c4662b1c305b99d7596cae:/floof/controllers/account.py diff --git a/floof/controllers/account.py b/floof/controllers/account.py index a32583c..6c36310 100644 --- a/floof/controllers/account.py +++ b/floof/controllers/account.py @@ -1,3 +1,4 @@ +import elixir import logging from openid.consumer.consumer import Consumer from openid.extensions.sreg import SRegRequest, SRegResponse @@ -8,9 +9,8 @@ from pylons import request, response, session, tmpl_context as c from pylons.controllers.util import abort, redirect_to from routes import url_for, request_config -from floof import model -from floof.model.meta import Session from floof.lib.base import BaseController, render +from floof.model.users import IdentityURL, User log = logging.getLogger(__name__) @@ -50,26 +50,25 @@ class AccountController(BaseController): try: # Grab an existing user record, if one exists - q = Session.query(model.User) \ - .filter(model.User.identity_urls.any(url=res.identity_url)) + q = User.query.filter(User.identity_urls.any(url=res.identity_url)) user = q.one() except NoResultFound: # Try to pull a name out of the SReg response sreg_res = SRegResponse.fromSuccessResponse(res) try: - username = sreg_res['nickname'] + username = unicode(sreg_res['nickname']) except: - username = 'Anonymous' + username = u'Anonymous' # Create db records - user = model.User(name=username) - Session.add(user) - identity_url = model.IdentityURL(url=res.identity_url) + user = User(name=username) + identity_url = IdentityURL(url=res.identity_url) user.identity_urls.append(identity_url) - Session.commit() + elixir.session.commit() # Remember who's logged in, and we're good to go session['user_id'] = user.id session.save() - return "Hello, %s from %s" % (user.name, res.identity_url) + # XXX send me where I came from + redirect_to('/')