Changeset - 52356a58c1f6
[Not reviewed]
default
0 2 0
Andrew Shadura - 10 years ago 2016-01-30 16:38:26
andrew@shadura.me
middleware: allow git and hg users to use email address instead of the username

This commit also replaces __get_user('default') with a call to a more widely
used User.get_default_user() function, and removes no longer really used
__get_user() methods from both SimpleHg and SimpleGit.
2 files changed with 4 insertions and 10 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/middleware/simplegit.py
Show inline comments
 
@@ -99,7 +99,7 @@ class SimpleGit(BaseVCSController):
 
        # CHECK ANONYMOUS PERMISSION
 
        #======================================================================
 
        if action in ['pull', 'push']:
 
            anonymous_user = self.__get_user('default')
 
            anonymous_user = User.get_default_user(cache=True)
 
            username = anonymous_user.username
 
            if anonymous_user.active:
 
                # ONLY check permissions if the user is activated
 
@@ -146,7 +146,7 @@ class SimpleGit(BaseVCSController):
 
                # CHECK PERMISSIONS FOR THIS REQUEST USING GIVEN USERNAME
 
                #==============================================================
 
                try:
 
                    user = self.__get_user(username)
 
                    user = User.get_by_username_or_email(username)
 
                    if user is None or not user.active:
 
                        return HTTPForbidden()(environ, start_response)
 
                    username = user.username
 
@@ -248,9 +248,6 @@ class SimpleGit(BaseVCSController):
 

	
 
        return repo_name
 

	
 
    def __get_user(self, username):
 
        return User.get_by_username(username)
 

	
 
    def __get_action(self, environ):
 
        """
 
        Maps git request commands into a pull or push command.
kallithea/lib/middleware/simplehg.py
Show inline comments
 
@@ -105,7 +105,7 @@ class SimpleHg(BaseVCSController):
 
        # CHECK ANONYMOUS PERMISSION
 
        #======================================================================
 
        if action in ['pull', 'push']:
 
            anonymous_user = self.__get_user('default')
 
            anonymous_user = User.get_default_user(cache=True)
 
            username = anonymous_user.username
 
            if anonymous_user.active:
 
                # ONLY check permissions if the user is activated
 
@@ -152,7 +152,7 @@ class SimpleHg(BaseVCSController):
 
                # CHECK PERMISSIONS FOR THIS REQUEST USING GIVEN USERNAME
 
                #==============================================================
 
                try:
 
                    user = self.__get_user(username)
 
                    user = User.get_by_username_or_email(username)
 
                    if user is None or not user.active:
 
                        return HTTPForbidden()(environ, start_response)
 
                    username = user.username
 
@@ -248,9 +248,6 @@ class SimpleHg(BaseVCSController):
 

	
 
        return repo_name
 

	
 
    def __get_user(self, username):
 
        return User.get_by_username(username)
 

	
 
    def __get_action(self, environ):
 
        """
 
        Maps mercurial request commands into a clone,pull or push command.
0 comments (0 inline, 0 general)