Skip to content

Commit

Permalink
✨ [#4398] Pass initial_data_reference from auth start to return view
Browse files Browse the repository at this point in the history
the initial data reference is passed from the SDK to the backend as part of the login URL. In order to pass it as part of the submission create body, it must be propagated from the authentication start/return views back to the SDK
  • Loading branch information
stevenbal committed Oct 10, 2024
1 parent d777da6 commit f9bdc8b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/openforms/authentication/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ class AuthenticationStartView(AuthenticationFlowBaseView):
register = register

def get(self, request: Request, slug: str, plugin_id: str):
# Store the initial data reference in the session, so it can be passed back
# in the `AuthenticationReturnView`
request.session["initial_data_reference"] = request.query_params.get(
"initial_data_reference"
)
form = self.get_object()
try:
plugin = self.register[plugin_id]
Expand Down Expand Up @@ -300,6 +305,7 @@ def _handle_return(self, request: Request, slug: str, plugin_id: str):
plugin. We must define ``get`` and ``post`` to have them properly show up and
be documented in the OAS.
"""
initial_data_reference = request.session.pop("initial_data_reference", None)
form = self.get_object()
try:
plugin = self.register[plugin_id]
Expand Down Expand Up @@ -339,6 +345,14 @@ def _handle_return(self, request: Request, slug: str, plugin_id: str):
if hasattr(request, "session") and FORM_AUTH_SESSION_KEY in request.session:
authentication_success.send(sender=self.__class__, request=request)

if initial_data_reference:
# Pass the initial data reference back to the SDK, to allow sending it
# with the submission create call
return HttpResponseRedirect(
furl(response.url)
.add({"initial_data_reference": initial_data_reference})
.url
)
return response

def _handle_co_sign(self, form: Form, plugin: BasePlugin) -> None:
Expand Down

0 comments on commit f9bdc8b

Please sign in to comment.