Skip to content

Commit

Permalink
fix: make REMOTE_ADDR optional in all cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mschoettle committed Mar 14, 2024
1 parent ba825f8 commit cafc7c0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions easyaudit/signals/auth_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def user_logged_in(sender, request, user, **kwargs):
'login_type': LoginEvent.LOGIN,
'username': getattr(user, user.USERNAME_FIELD),
'user_id': getattr(user, 'id', None),
'remote_ip': request.META.get(REMOTE_ADDR_HEADER, "")
'remote_ip': request.META.get(REMOTE_ADDR_HEADER, '')
})
except Exception:
if should_propagate_exceptions():
Expand All @@ -32,7 +32,7 @@ def user_logged_out(sender, request, user, **kwargs):
'login_type': LoginEvent.LOGOUT,
'username': getattr(user, user.USERNAME_FIELD),
'user_id': getattr(user, 'id', None),
'remote_ip': request.META[REMOTE_ADDR_HEADER]
'remote_ip': request.META.get(REMOTE_ADDR_HEADER, '')
})
except Exception:
if should_propagate_exceptions():
Expand All @@ -47,7 +47,7 @@ def user_login_failed(sender, credentials, **kwargs):
login_event = audit_logger.login({
'login_type': LoginEvent.FAILED,
'username': credentials[user_model.USERNAME_FIELD],
'remote_ip': request.META[REMOTE_ADDR_HEADER]
'remote_ip': request.META.get(REMOTE_ADDR_HEADER, '')
})
except Exception:
if should_propagate_exceptions():
Expand Down

0 comments on commit cafc7c0

Please sign in to comment.