Added logout. Removed magical routing.
authorEevee <git@veekun.com>
Mon, 5 Oct 2009 04:00:03 +0000 (21:00 -0700)
committerEevee <git@veekun.com>
Mon, 5 Oct 2009 04:00:15 +0000 (21:00 -0700)
floof/config/routing.py
floof/controllers/account.py
floof/templates/base.mako

index ff850b8..c8f9e4e 100644 (file)
@@ -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/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('/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
     return map
index 0c53a6d..e4f39f3 100644 (file)
@@ -72,6 +72,17 @@ class AccountController(BaseController):
         # XXX send me where I came from
         redirect_to('/')
 
         # 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."""
 
     def register(self):
         """Logging in with an unrecognized identity URL redirects here."""
 
index e36f3ea..f50f56a 100644 (file)
@@ -16,7 +16,9 @@ ${h.end_form()}
 
     <div id="user">
         % if c.user:
 
     <div id="user">
         % if c.user:
-        <p>Logged in as ${c.user.name}</p>
+        <form action="${url(controller='account', action='logout')}" method="POST">
+        <p>Logged in as ${c.user.name}.  ${h.submit(None, 'Log out')}</p>
+        </form>
         % else:
         <form action="${url(controller='account', action='login_begin')}" method="POST">
         <p>
         % else:
         <form action="${url(controller='account', action='login_begin')}" method="POST">
         <p>