From: Eevee Date: Mon, 5 Oct 2009 04:00:03 +0000 (-0700) Subject: Added logout. Removed magical routing. X-Git-Url: http://git.veekun.com/zzz-floof.git/commitdiff_plain/5e8cb14114fb2a6f8b5c7c717c7f6e580ed5a95a Added logout. Removed magical routing. --- diff --git a/floof/config/routing.py b/floof/config/routing.py index ff850b8..c8f9e4e 100644 --- a/floof/config/routing.py +++ b/floof/config/routing.py @@ -25,12 +25,10 @@ def make_map(): map.connect('/account/login', controller='account', action='login') map.connect('/account/login_begin', controller='account', action='login_begin', **require_POST) map.connect('/account/login_finish', controller='account', action='login_finish') + map.connect('/account/logout', controller='account', action='logout', **require_POST) map.connect('/account/register', controller='account', action='register') map.connect('/account/register_finish', controller='account', action='register_finish', **require_POST) map.connect('/search', controller='search', action='index') - map.connect('/{controller}/{action}') - map.connect('/{controller}/{action}/{id}') - return map diff --git a/floof/controllers/account.py b/floof/controllers/account.py index 0c53a6d..e4f39f3 100644 --- a/floof/controllers/account.py +++ b/floof/controllers/account.py @@ -72,6 +72,17 @@ class AccountController(BaseController): # XXX send me where I came from redirect_to('/') + def logout(self): + """Log user out.""" + + if 'user_id' in session: + del session['user_id'] + session.save() + + # XXX success message + # XXX send me where I came from + redirect_to('/') + def register(self): """Logging in with an unrecognized identity URL redirects here.""" diff --git a/floof/templates/base.mako b/floof/templates/base.mako index e36f3ea..f50f56a 100644 --- a/floof/templates/base.mako +++ b/floof/templates/base.mako @@ -16,7 +16,9 @@ ${h.end_form()}
% if c.user: -

Logged in as ${c.user.name}

+
+

Logged in as ${c.user.name}. ${h.submit(None, 'Log out')}

+
% else: