~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/dispatch/request.py

  • Committer: chadnickbok
  • Date: 2009-01-13 03:13:59 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1104
Created a new app, logout, which when given a GET
request opens a new page, with a button asking for
confirmation to logout.

When given a POST request, logs the user out.

Fixes issue #65

Show diffs side-by-side

added added

removed removed

Lines of Context:
252
252
            # This includes binary strings.
253
253
            self.apache_req.write(string, flush)
254
254
 
 
255
    def logout(self):
 
256
        """Log out the current user by destroying the session state.
 
257
        Then redirect to the top-level IVLE page."""
 
258
        # List of cookies that IVLE uses (to be removed at logout)
 
259
        ivle_cookies = ["ivleforumcookie", "clipboard"]
 
260
        
 
261
        if hasattr(self, 'session'):
 
262
            self.session.invalidate()
 
263
            self.session.delete()
 
264
            # Invalidates all IVLE cookies
 
265
            all_cookies = Cookie.get_cookies(self)
 
266
            for cookie in all_cookies:
 
267
                if cookie in ivle_cookies:
 
268
                    self.add_cookie(Cookie.Cookie(cookie,'',expires=1,path='/'))
 
269
        self.throw_redirect(common.util.make_path('')) 
 
270
 
 
271
 
255
272
    def flush(self):
256
273
        """Flushes the output buffer."""
257
274
        self.apache_req.flush()