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.
  • Loading branch information
vaszig committed Dec 20, 2024
1 parent 260a985 commit 592f1f3
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/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,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 fields, values

invoke_plugin_args = []
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 @@ -626,3 +626,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

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

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

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

0 comments on commit 592f1f3

Please sign in to comment.