From fa9db46bfec4b796e3ae5644a3808bed4b153315 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Thu, 17 Jan 2013 22:36:49 +0100 Subject: [PATCH] Define a smaller cookie age and protect against deleted users. see #307 --- modoboa/core/templates/settings.py | 2 ++ modoboa/lib/templatetags/libextras.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modoboa/core/templates/settings.py b/modoboa/core/templates/settings.py index af94907df..51dae7c3b 100644 --- a/modoboa/core/templates/settings.py +++ b/modoboa/core/templates/settings.py @@ -159,6 +159,8 @@ AUTHENTICATION_BACKENDS = ( 'modoboa.lib.authbackends.SimpleBackend', ) +SESSION_COOKIE_AGE = 600 + # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to # the site admins on every HTTP 500 error when DEBUG=False. diff --git a/modoboa/lib/templatetags/libextras.py b/modoboa/lib/templatetags/libextras.py index 315bb39de..95710150a 100644 --- a/modoboa/lib/templatetags/libextras.py +++ b/modoboa/lib/templatetags/libextras.py @@ -193,7 +193,12 @@ class ConnectedUsers(template.Node): uid_list.append(uid) # Query all logged in users based on id list - context[self.varname] = [User.objects.get(pk=uid) for uid in uid_list] + context[self.varname] = [] + for uid in uid_list: + try: + context[self.varname].append(User.objects.get(pk=uid)) + except User.DoesNotExist: + print "unknown user" return '' @register.tag