Do not create AuditEvent if updating the User.last_login
This commit is contained in:
parent
4a54602cc6
commit
0d6f7aa3cc
@ -54,7 +54,8 @@ class AuditableMixin(object):
|
||||
|
||||
@staticmethod
|
||||
def audit_update(mapper, connection, target):
|
||||
if AuditableMixin.get_changes(target):
|
||||
changes = AuditableMixin.get_changes(target)
|
||||
if changes and not "last_login" in changes:
|
||||
target.create_audit_event(connection, target, ACTION_UPDATE)
|
||||
|
||||
def get_changes(self):
|
||||
|
@ -51,3 +51,9 @@ def test_logging_audit_event_on_update(mock_logger):
|
||||
assert event_log["action"] == "update"
|
||||
|
||||
assert "update" in mock_logger.extras[1]["tags"]
|
||||
|
||||
|
||||
def test_does_not_log_user_update_when_updating_last_login(mock_logger):
|
||||
user = UserFactory.create()
|
||||
Users.update_last_login(user)
|
||||
assert "Audit Event update" not in mock_logger.messages
|
||||
|
Loading…
x
Reference in New Issue
Block a user