##// END OF EJS Templates
moved checking for user in session to wrapper function of LoginRequired decorator since it was working quite strange.
marcink -
r199:78e406a4 default
parent child Browse files
Show More
@@ -41,7 +41,7 class AuthUser(object):
41 """
41 """
42 A simple object that handles a mercurial username for authentication
42 A simple object that handles a mercurial username for authentication
43 """
43 """
44 username = 'Empty'
44 username = 'None'
45 is_authenticated = False
45 is_authenticated = False
46 is_admin = False
46 is_admin = False
47 permissions = set()
47 permissions = set()
@@ -61,16 +61,17 class LoginRequired(object):
61 pass
61 pass
62
62
63 def __call__(self, func):
63 def __call__(self, func):
64 user = session.get('hg_app_user', AuthUser())
65 log.info('Checking login required for %s', user.username)
66
64
67 @wraps(func)
65 @wraps(func)
68 def _wrapper(*fargs, **fkwargs):
66 def _wrapper(*fargs, **fkwargs):
67 user = session.get('hg_app_user', AuthUser())
68 log.info('Checking login required for user:%s', user.username)
69 if user.is_authenticated:
69 if user.is_authenticated:
70 log.info('user %s is authenticated', user.username)
70 log.info('user %s is authenticated', user.username)
71 func(*fargs)
71 func(*fargs)
72 else:
72 else:
73 logging.info('user %s not authenticated', user.username)
73 logging.info('user %s not authenticated', user.username)
74 logging.info('redirecting to login page')
74 return redirect(url('login_home'))
75 return redirect(url('login_home'))
75
76
76 return _wrapper
77 return _wrapper
General Comments 0
You need to be logged in to leave comments. Login now