Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#4825] Log prefill retrieve empty only for the used authentication flow #4959

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
Loading