projects
/
zzz-spline-users.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added very basic permission system. #71
[zzz-spline-users.git]
/
splinext
/
users
/
controllers
/
accounts.py
diff --git
a/splinext/users/controllers/accounts.py
b/splinext/users/controllers/accounts.py
index
9add733
..
c70ad6d
100644
(file)
--- a/
splinext/users/controllers/accounts.py
+++ b/
splinext/users/controllers/accounts.py
@@
-1,5
+1,5
@@
import logging
import logging
-from openid.consumer.consumer import Consumer
+from openid.consumer.consumer import Consumer
, SUCCESS, CANCEL
from openid.extensions.sreg import SRegRequest, SRegResponse
from openid.store.filestore import FileOpenIDStore
from openid.yadis.discover import DiscoveryFailure
from openid.extensions.sreg import SRegRequest, SRegResponse
from openid.store.filestore import FileOpenIDStore
from openid.yadis.discover import DiscoveryFailure
@@
-9,10
+9,10
@@
from pylons import config, request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect_to
from routes import request_config
from pylons.controllers.util import abort, redirect_to
from routes import request_config
-from spline import model
from spline.model import meta
from spline.lib import helpers as h
from spline.lib.base import BaseController, render
from spline.model import meta
from spline.lib import helpers as h
from spline.lib.base import BaseController, render
+from splinext.users import model as users_model
log = logging.getLogger(__name__)
log = logging.getLogger(__name__)
@@
-69,13
+69,17
@@
class AccountsController(BaseController):
return_url = url(host=host, controller='accounts', action='login_finish')
res = cons.complete(request.params, return_url)
return_url = url(host=host, controller='accounts', action='login_finish')
res = cons.complete(request.params, return_url)
- if res.status != 'success':
+ if res.status == CANCEL:
+ # I guess.. just.. back to the homepage?
+ h.flash(u"""Login canceled.""", icon='user-silhouette')
+ redirect_to(url('/'))
+ elif res.status != SUCCESS:
return 'Error! %s' % res.message
try:
# Grab an existing user record, if one exists
return 'Error! %s' % res.message
try:
# Grab an existing user record, if one exists
- q = meta.Session.query(model.User) \
- .filter(model.User.openids.any(openid=res.identity_url))
+ q = meta.Session.query(
users_
model.User) \
+ .filter(
users_
model.User.openids.any(openid=res.identity_url))
user = q.one()
except NoResultFound:
# Try to pull a name out of the SReg response
user = q.one()
except NoResultFound:
# Try to pull a name out of the SReg response
@@
-87,10
+91,10
@@
class AccountsController(BaseController):
username = 'Anonymous'
# Create db records
username = 'Anonymous'
# Create db records
- user = model.User(name=username)
+ user =
users_
model.User(name=username)
meta.Session.add(user)
meta.Session.add(user)
- openid = model.OpenID(openid=res.identity_url)
+ openid =
users_
model.OpenID(openid=res.identity_url)
user.openids.append(openid)
meta.Session.commit()
user.openids.append(openid)
meta.Session.commit()