changeset 7732:1f831a8a590c

auth: fix failure when editing inactive users AuthUser._fill_data did not work on users that not were active, and we could thus not even *talk* about inactive users. To make things more simple, inline the function. That also makes it clear that dbuser can't be None.
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 06 Jun 2019 23:47:43 +0200
parents bac0ddd79c74
children 460cfae11203
files kallithea/lib/auth.py
diffstat 1 files changed, 7 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/auth.py	Wed Jan 23 12:44:17 2019 +0100
+++ b/kallithea/lib/auth.py	Thu Jun 06 23:47:43 2019 +0200
@@ -440,32 +440,18 @@
             assert dbuser is not None
             log.debug('Auth User lookup by database user %s', dbuser)
 
-        if self._fill_data(dbuser):
-            self.is_default_user = dbuser.is_default_user
-        else:
-            assert dbuser.is_default_user
-            assert not self.username
+        log.debug('filling %s data', dbuser)
+        self.is_anonymous = dbuser.is_default_user
+        if dbuser.is_default_user and not dbuser.active:
             self.username = 'None'
             self.is_default_user = False
-        self.is_anonymous = dbuser.is_default_user
-
-        log.debug('Auth User is now %s', self)
-
-    def _fill_data(self, dbuser):
-        """
-        Copies database fields from a `db.User` to this `AuthUser`. Does
-        not copy `api_keys` and `permissions` attributes.
-
-        Checks that `dbuser` is `active` (and not None) before copying;
-        returns True on success.
-        """
-        if dbuser is not None and dbuser.active:
-            log.debug('filling %s data', dbuser)
+        else:
+            # copy non-confidential database fields from a `db.User` to this `AuthUser`.
             for k, v in dbuser.get_dict().iteritems():
                 assert k not in ['api_keys', 'permissions']
                 setattr(self, k, v)
-            return True
-        return False
+            self.is_default_user = dbuser.is_default_user
+        log.debug('Auth User is now %s', self)
 
     @LazyProperty
     def permissions(self):