Mercurial > kallithea
changeset 7480:d22a7430999f
auth: change get_allowed_ips to be more resilient when operating on a cached default user
Before, random changes to how things are fetched and cached across database
sessions could cause get_allowed_ips to fail with:
DetachedInstanceError: Instance <User> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/bhk3)
Instead, just check for user_id, using same pattern as a bit later in same function.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Tue, 25 Dec 2018 20:31:12 +0100 |
parents | be37a0b982e9 |
children | cb472dfe807d |
files | kallithea/lib/auth.py |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/auth.py Tue Dec 25 20:31:12 2018 +0100 +++ b/kallithea/lib/auth.py Tue Dec 25 20:31:12 2018 +0100 @@ -686,8 +686,8 @@ _set = set() if inherit_from_default: - default_ips = UserIpMap.query().filter(UserIpMap.user == - User.get_default_user(cache=True)) + default_ips = UserIpMap.query().filter(UserIpMap.user_id == + User.get_default_user(cache=True).user_id) if cache: default_ips = default_ips.options(FromCache("sql_cache_short", "get_user_ips_default"))