projects
/
zzz-spline-users.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
1e23823
)
Implemented logout and generally fixed the in/out sequence. #69
author
Eevee
<git@veekun.com>
Thu, 22 Apr 2010 07:02:25 +0000
(
00:02
-0700)
committer
Eevee
<git@veekun.com>
Fri, 23 Apr 2010 04:37:14 +0000
(21:37 -0700)
spline/plugins/users/__init__.py
patch
|
blob
|
history
spline/plugins/users/controllers/accounts.py
patch
|
blob
|
history
spline/plugins/users/templates/widgets/user_state.mako
patch
|
blob
|
history
diff --git
a/spline/plugins/users/__init__.py
b/spline/plugins/users/__init__.py
index
92a825c
..
5173931
100644
(file)
--- a/
spline/plugins/users/__init__.py
+++ b/
spline/plugins/users/__init__.py
@@
-14,6
+14,7
@@
def add_routes_hook(map, *args, **kwargs):
"""Hook to inject some of our behavior into the routes configuration."""
map.connect('/accounts/login_begin', controller='accounts', action='login_begin')
map.connect('/accounts/login_finish', controller='accounts', action='login_finish')
"""Hook to inject some of our behavior into the routes configuration."""
map.connect('/accounts/login_begin', controller='accounts', action='login_begin')
map.connect('/accounts/login_finish', controller='accounts', action='login_finish')
+ map.connect('/accounts/logout', controller='accounts', action='logout')
def check_userid_hook(action, **params):
"""Hook to see if a user is logged in and, if so, stick a user object in
def check_userid_hook(action, **params):
"""Hook to see if a user is logged in and, if so, stick a user object in
diff --git
a/spline/plugins/users/controllers/accounts.py
b/spline/plugins/users/controllers/accounts.py
index
03c9392
..
ba2fa26
100644
(file)
--- a/
spline/plugins/users/controllers/accounts.py
+++ b/
spline/plugins/users/controllers/accounts.py
@@
-10,6
+10,7
@@
from routes import request_config
from spline import model
from spline.model import meta
from spline import model
from spline.model import meta
+from spline.lib import helpers as h
from spline.lib.base import BaseController, render
log = logging.getLogger(__name__)
from spline.lib.base import BaseController, render
log = logging.getLogger(__name__)
@@
-76,4
+77,19
@@
class AccountsController(BaseController):
session['user_id'] = user.id
session.save()
session['user_id'] = user.id
session.save()
- redirect_to(url('/'))
+ h.flash(u"""Hello, {0}!""".format(user.name),
+ icon='user')
+
+ redirect_to('/', _code=303)
+
+ def logout(self):
+ """Logs the user out."""
+
+ if 'user_id' in session:
+ del session['user_id']
+ session.save()
+
+ h.flash(u"""Logged out.""",
+ icon='user-silhouette')
+
+ redirect_to('/', _code=303)
diff --git
a/spline/plugins/users/templates/widgets/user_state.mako
b/spline/plugins/users/templates/widgets/user_state.mako
index
d279dc4
..
dbc73a0
100644
(file)
--- a/
spline/plugins/users/templates/widgets/user_state.mako
+++ b/
spline/plugins/users/templates/widgets/user_state.mako
@@
-1,9
+1,12
@@
-${h.form(url(controller='accounts', action='login_begin'), id='user')}
- % if c.user:
+% if c.user:
+${h.form(url(controller='accounts', action='logout'), id='user')}
Logged in as ${c.user.name}.
Logged in as ${c.user.name}.
- % else:
+ <input type="submit" value="Log out">
+${h.end_form()}
+% else:
+${h.form(url(controller='accounts', action='login_begin'), id='user')}
<img src="${h.static_uri('spline', 'icons/openid.png')}">
<input type="text" name="openid" size="30">
<input type="submit" value="Log in">
<img src="${h.static_uri('spline', 'icons/openid.png')}">
<input type="text" name="openid" size="30">
<input type="submit" value="Log in">
- % endif
${h.end_form()}
${h.end_form()}
+% endif