# HG changeset patch # User Marcin Kuzminski # Date 2018-07-04 10:19:08 # Node ID d1dcf3737a704a5276e515b43a30b771222988d8 # Parent 1b6297eba8650425c4fdb274b3ba392ed8fc1d40 ip-restritions: fix issue with loading empty IP rules for non-logged not-anonymous users. This case won't have any IP rules set. And we accidentally loaded them becuase of no empty user filter was present. This caused some odd display warnings for users. diff --git a/rhodecode/lib/auth.py b/rhodecode/lib/auth.py --- a/rhodecode/lib/auth.py +++ b/rhodecode/lib/auth.py @@ -1292,10 +1292,15 @@ class AuthUser(object): # we get deleted objects here, we just skip them pass - user_ips = UserIpMap.query().filter(UserIpMap.user_id == user_id) - if cache: - user_ips = user_ips.options( - FromCache("sql_cache_short", "get_user_ips_%s" % user_id)) + # NOTE:(marcink) we don't want to load any rules for empty + # user_id which is the case of access of non logged users when anonymous + # access is disabled + user_ips = [] + if user_id: + user_ips = UserIpMap.query().filter(UserIpMap.user_id == user_id) + if cache: + user_ips = user_ips.options( + FromCache("sql_cache_short", "get_user_ips_%s" % user_id)) for ip in user_ips: try: