From 791e88ffc1cb1cb896c96121027060b916e85fbf Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 3 Mar 2019 17:21:58 +0100 Subject: [PATCH] Fix negate on FieldMatcherPolicy --- passbook/core/models.py | 3 +-- passbook/core/policies.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/passbook/core/models.py b/passbook/core/models.py index 33e93d5b4..cdef3c754 100644 --- a/passbook/core/models.py +++ b/passbook/core/models.py @@ -284,8 +284,7 @@ class FieldMatcherPolicy(Policy): if self.match_action == FieldMatcherPolicy.MATCH_REGEXP: pattern = re.compile(self.value) passes = bool(pattern.match(user_field_value)) - if self.negate: - passes = not passes + LOGGER.debug("User got '%r'", passes) return passes diff --git a/passbook/core/policies.py b/passbook/core/policies.py index 6bacb64ab..3abfb0b27 100644 --- a/passbook/core/policies.py +++ b/passbook/core/policies.py @@ -25,6 +25,7 @@ def _policy_engine_task(user_pk, policy_pk, **kwargs): # Invert result if policy.negate is set if policy_obj.negate: policy_result = not policy_result + LOGGER.debug("Policy %r#%s got %s", policy_obj.name, policy_obj.pk.hex, policy_result) return policy_obj.action, policy_result, message class PolicyEngine: