Changeset 4610 for waeup


Ignore:
Timestamp:
2 Jan 2010, 02:16:52 (15 years ago)
Author:
uli
Message:
  • Add logout page
  • Fix missing return in login handling.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-layout/src/waeup/browser/pages.py

    r4609 r4610  
    66from waeup.interfaces import IUniversity, IWAeUPObject
    77from waeup.widgets.interfaces import ITableProvider
     8from zope.app.security.interfaces import (IAuthentication,
     9                                          IUnauthenticatedPrincipal,
     10                                          ILogout)
     11from zope.component import getUtility
    812
    913grok.templatedir('templates')
    1014
    1115#
    12 # Login pages...
     16# Login/logout pages...
    1317#
    1418
     
    3337                    return
    3438                self.redirect(self.camefrom)
     39                return
    3540            self.flash('You entered wrong credentials!')
    3641
     
    5055    grok.template('loginstudentpage')
    5156    title = u'Student Login'
     57
     58class LogoutPage(WAeUPPage):
     59    """A logout page. Calling this page will log the current user out.
     60    """
     61    grok.context(IWAeUPObject)
     62    grok.name('logout')
     63   
     64    def update(self):
     65        if not IUnauthenticatedPrincipal.providedBy(self.request.principal):
     66            auth = getUtility(IAuthentication)
     67            ILogout(auth).logout(self.request)
     68            self.flash("You have been logged out. Thanks for using WAeUP SRP!")
     69        self.redirect(self.url(self.context))
    5270
    5371
Note: See TracChangeset for help on using the changeset viewer.