changeset 199:78e406a4c58e

moved checking for user in session to wrapper function of LoginRequired decorator since it was working quite strange.
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 22 May 2010 20:47:34 +0200
parents c097458480a5
children b48ebda822a4
files pylons_app/lib/auth.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pylons_app/lib/auth.py	Sat May 22 19:30:20 2010 +0200
+++ b/pylons_app/lib/auth.py	Sat May 22 20:47:34 2010 +0200
@@ -41,7 +41,7 @@
     """
     A simple object that handles a mercurial username for authentication
     """
-    username = 'Empty'
+    username = 'None'
     is_authenticated = False
     is_admin = False
     permissions = set()
@@ -61,16 +61,17 @@
         pass
     
     def __call__(self, func):
-        user = session.get('hg_app_user', AuthUser())
-        log.info('Checking login required for %s', user.username)
         
         @wraps(func)
         def _wrapper(*fargs, **fkwargs):
+            user = session.get('hg_app_user', AuthUser())
+            log.info('Checking login required for user:%s', user.username)            
             if user.is_authenticated:
                     log.info('user %s is authenticated', user.username)
                     func(*fargs)
             else:
                 logging.info('user %s not authenticated', user.username)
+                logging.info('redirecting to login page')
                 return redirect(url('login_home'))
 
         return _wrapper