From e990757bda4ddc4607b65397ba0d00a1783b2d4e Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 6 Feb 2024 03:20:46 +0200 Subject: [PATCH] fix 500 error --- files/routes/allroutes.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/files/routes/allroutes.py b/files/routes/allroutes.py index b7b1c25ee..b9c6a0882 100644 --- a/files/routes/allroutes.py +++ b/files/routes/allroutes.py @@ -72,16 +72,17 @@ def after_request(response): if FEATURES['IP_LOGGING']: if g.v.admin_level < PERMS['EXEMPT_FROM_IP_LOGGING'] and user_id != CARP_ID: ip = get_IP() - existing = g.db.query(IPLog).filter_by(user_id=user_id, ip=ip).one_or_none() - if existing: - existing.last_used = time.time() - g.db.add(existing) - else: - ip_log = IPLog( - user_id=user_id, - ip=ip, - ) - g.db.add(ip_log) + if ip: + existing = g.db.query(IPLog).filter_by(user_id=user_id, ip=ip).one_or_none() + if existing: + existing.last_used = time.time() + g.db.add(existing) + else: + ip_log = IPLog( + user_id=user_id, + ip=ip, + ) + g.db.add(ip_log) _commit_and_close_db()