# HG changeset patch # User Marcin Kuzminski # Date 1340293721 -7200 # Node ID 94ef0b609d17f618317d715f24d0efcac72fe4a4 # Parent c919d8c4f6a29da5dccd7fa8ed1c9478ae125eeb possible fix for #486 undefined variable username - cleaned a code on git/hg middleware diff -r c919d8c4f6a2 -r 94ef0b609d17 rhodecode/lib/middleware/simplegit.py --- a/rhodecode/lib/middleware/simplegit.py Thu Jun 21 01:34:11 2012 +0200 +++ b/rhodecode/lib/middleware/simplegit.py Thu Jun 21 17:48:41 2012 +0200 @@ -167,21 +167,20 @@ #============================================================== # CHECK PERMISSIONS FOR THIS REQUEST USING GIVEN USERNAME #============================================================== - if action in ['pull', 'push']: - try: - user = self.__get_user(username) - if user is None or not user.active: - return HTTPForbidden()(environ, start_response) - username = user.username - except: - log.error(traceback.format_exc()) - return HTTPInternalServerError()(environ, - start_response) + try: + user = self.__get_user(username) + if user is None or not user.active: + return HTTPForbidden()(environ, start_response) + username = user.username + except: + log.error(traceback.format_exc()) + return HTTPInternalServerError()(environ, start_response) - #check permissions for this repository - perm = self._check_permission(action, user, repo_name) - if perm is not True: - return HTTPForbidden()(environ, start_response) + #check permissions for this repository + perm = self._check_permission(action, user, repo_name) + if perm is not True: + return HTTPForbidden()(environ, start_response) + extras = { 'ip': ipaddr, 'username': username, diff -r c919d8c4f6a2 -r 94ef0b609d17 rhodecode/lib/middleware/simplehg.py --- a/rhodecode/lib/middleware/simplehg.py Thu Jun 21 01:34:11 2012 +0200 +++ b/rhodecode/lib/middleware/simplehg.py Thu Jun 21 17:48:41 2012 +0200 @@ -70,7 +70,7 @@ return self.application(environ, start_response) ipaddr = self._get_ip_addr(environ) - + username = None # skip passing error to error controller environ['pylons.status_code_redirect'] = True @@ -131,21 +131,19 @@ #============================================================== # CHECK PERMISSIONS FOR THIS REQUEST USING GIVEN USERNAME #============================================================== - if action in ['pull', 'push']: - try: - user = self.__get_user(username) - if user is None or not user.active: - return HTTPForbidden()(environ, start_response) - username = user.username - except: - log.error(traceback.format_exc()) - return HTTPInternalServerError()(environ, - start_response) + try: + user = self.__get_user(username) + if user is None or not user.active: + return HTTPForbidden()(environ, start_response) + username = user.username + except: + log.error(traceback.format_exc()) + return HTTPInternalServerError()(environ, start_response) - #check permissions for this repository - perm = self._check_permission(action, user, repo_name) - if perm is not True: - return HTTPForbidden()(environ, start_response) + #check permissions for this repository + perm = self._check_permission(action, user, repo_name) + if perm is not True: + return HTTPForbidden()(environ, start_response) # extras are injected into mercurial UI object and later available # in hg hooks executed by rhodecode