Changeset - b92c2e4324b0
[Not reviewed]
default
0 3 0
Søren Løvborg - 10 years ago 2015-07-26 13:58:50
kwi@kwi.dk
auth: remove redundant AuthUser constructor arguments

AuthUser looks up the user based on the first of `user_id`, `api_key`
and `username` that is not None *and* does not refer to the default
(anonymous) user. In practice, the arguments always refer to the same
user, so there's no point in specifying more than one of them.
3 files changed with 2 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/api/__init__.py
Show inline comments
 
@@ -158,7 +158,7 @@ class JSONRPCController(WSGIController):
 
                return jsonrpc_error(retid=self._req_id,
 
                                     message='Invalid API key')
 

	
 
            auth_u = AuthUser(u.user_id, self._req_api_key)
 
            auth_u = AuthUser(u.user_id)
 
            if not AuthUser.check_ip_allowed(auth_u, ip_addr):
 
                return jsonrpc_error(retid=self._req_id,
 
                        message='request from IP:%s not allowed' % (ip_addr,))
kallithea/lib/auth.py
Show inline comments
 
@@ -643,7 +643,6 @@ class AuthUser(object):
 

	
 
        au = AuthUser(
 
            user_id=cookie.get('user_id'),
 
            username=cookie.get('username'),
 
            is_external_auth=cookie.get('is_external_auth', False),
 
        )
 
        if not au.is_authenticated and au.user_id is not None:
kallithea/model/db.py
Show inline comments
 
@@ -511,8 +511,7 @@ class User(Base, BaseModel):
 
        Returns instance of AuthUser for this user
 
        """
 
        from kallithea.lib.auth import AuthUser
 
        return AuthUser(user_id=self.user_id, api_key=self.api_key,
 
                        username=self.username)
 
        return AuthUser(user_id=self.user_id)
 

	
 
    @hybrid_property
 
    def user_data(self):
0 comments (0 inline, 0 general)