diff options
author | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2014-11-18 05:36:58 +0100 |
---|---|---|
committer | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2014-11-19 02:15:56 +0100 |
commit | 31098aa6569bb40beb23d92d63704cee33ee85b6 (patch) | |
tree | 70036144b93fd4abd21d5dbfd5542a3eb461b5fc | |
parent | f71bd73cb6fd2ebf5fd10145191a7fd55003558d (diff) | |
download | padlite-teams-31098aa6569bb40beb23d92d63704cee33ee85b6.tar.gz padlite-teams-31098aa6569bb40beb23d92d63704cee33ee85b6.tar.bz2 padlite-teams-31098aa6569bb40beb23d92d63704cee33ee85b6.zip |
auth: delete current sessions on logout
On logout all session from the current bowser window are cleared. We generate
a uuid on login (and safe this in the flask session object) and delete all
padlite session with this uuid on logout.
-rw-r--r-- | auth.py | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1,8 +1,11 @@ from flask_peewee.auth import Auth -from models import User +from flask import session +from models import User, Session from app import app, db, pad from datetime import datetime +from padlite import APIException import ldap +import uuid class LdapAuth(Auth): def get_user_model(self): @@ -36,8 +39,19 @@ class LdapAuth(Auth): def login_user(self, user): user.last_login = datetime.now() user.save() + session['uuid'] = uuid.uuid4() return super(LdapAuth, self).login_user(user) + def logout_user(self): + if 'uuid' in session: + for s in Session.select().where(Session.uuid == session['uuid']): + try: + s.delete_instance() + except APIException: + pass + del session['uuid'] + return super(LdapAuth, self).logout_user() + def _format_dn(self, attr, with_base_dn = True): if with_base_dn: attr.extend(app.config['LDAP']['base_dn']) |