Skip to content

Commit

Permalink
[#4825] Log prefill retrieve empty only for the used authentication flow
Browse files Browse the repository at this point in the history
This is a fix which is meant for backporting. The 'proper' fix will be
implemented in a different PR, out of the scope of the v3.0.

Backport-of: #4959
  • Loading branch information
vaszig committed Dec 23, 2024
1 parent d428e39 commit 0ccae6f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/openforms/prefill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ def invoke_plugin(
if values:
logevent.prefill_retrieve_success(submission, plugin, fields)
else:
logevent.prefill_retrieve_empty(submission, plugin, fields)
if (required_attribute := plugin.requires_auth) is None or (
(auth_info := getattr(submission, "auth_info", None))
and auth_info.attribute == required_attribute
):
logevent.prefill_retrieve_empty(submission, plugin, fields)

return plugin_id, identifier_role, values

Expand Down
33 changes: 33 additions & 0 deletions src/openforms/prefill/tests/test_prefill_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,3 +627,36 @@ class TestPlugin(BasePlugin):
result = plugin.get_identifier_value(submission, IdentifierRoles.main)

self.assertEqual("123123123", result)

def test_prefill_logging_with_mismatching_login_method(self):
components = [
{
"key": "mainPersonName",
"type": "textfield",
"prefill": {
"plugin": "demo",
"attribute": "naam.voornamen",
"identifierRole": IdentifierRoles.main,
},
},
]
submission = SubmissionFactory.from_components(
components_list=components, kvk="69599084"
)
register = Registry()

@register("demo")
class MismatchPlugin(DemoPrefill):
requires_auth = AuthAttribute.bsn

@classmethod
def get_prefill_values(cls, submission, attributes, identifier_role):
return {}

apply_prefill(
configuration={"components": components},
submission=submission,
register=register,
)

self.assertFalse(TimelineLogProxy.objects.exists())

0 comments on commit 0ccae6f

Please sign in to comment.