changeset 5321:b92c2e4324b0

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.
author Søren Løvborg <kwi@kwi.dk>
date Sun, 26 Jul 2015 13:58:50 +0200
parents 837fc99ca140
children 789c98a9306d
files kallithea/controllers/api/__init__.py kallithea/lib/auth.py kallithea/model/db.py
diffstat 3 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/api/__init__.py	Sun Jul 26 13:58:50 2015 +0200
+++ b/kallithea/controllers/api/__init__.py	Sun Jul 26 13:58:50 2015 +0200
@@ -158,7 +158,7 @@
                 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,))
--- a/kallithea/lib/auth.py	Sun Jul 26 13:58:50 2015 +0200
+++ b/kallithea/lib/auth.py	Sun Jul 26 13:58:50 2015 +0200
@@ -643,7 +643,6 @@
 
         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:
--- a/kallithea/model/db.py	Sun Jul 26 13:58:50 2015 +0200
+++ b/kallithea/model/db.py	Sun Jul 26 13:58:50 2015 +0200
@@ -511,8 +511,7 @@
         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):