# HG changeset patch # User Mads Kiilerich # Date 2019-06-06 21:47:43 # Node ID 1f831a8a590cd42267b16463541d6f829f3c40de # Parent bac0ddd79c74f72aa77bd552e98a8b9c796b2884 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. diff --git a/kallithea/lib/auth.py b/kallithea/lib/auth.py --- a/kallithea/lib/auth.py +++ b/kallithea/lib/auth.py @@ -440,32 +440,18 @@ class AuthUser(object): 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):