Skip to content

Commit

Permalink
🐛 [open-formulieren/open-forms#4546] Properly pass initial_data_refer…
Browse files Browse the repository at this point in the history
…ence

previously this was added as a query param to the login URL, but to pass it correctly to the backend it should be added to the nextUrl query params on the login URL
  • Loading branch information
stevenbal committed Nov 5, 2024
1 parent 6352de4 commit aafcf1c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/FormStart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const FormStart = ({form, submission, onFormStart, onDestroySession, initialData
<LoginOptions
form={form}
onFormStart={onFormStart}
extraParams={{initial_data_reference: initialDataReference}}
extraNextParams={{initial_data_reference: initialDataReference}}
/>
)}
</Card>
Expand Down
4 changes: 2 additions & 2 deletions src/components/LoginOptions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Types from 'types';

import LoginOptionsDisplay from './LoginOptionsDisplay';

const LoginOptions = ({form, onFormStart, extraParams = {}}) => {
const LoginOptions = ({form, onFormStart, extraNextParams = {}}) => {
const config = useContext(ConfigContext);

const loginAsYourselfOptions = [];
Expand All @@ -18,7 +18,7 @@ const LoginOptions = ({form, onFormStart, extraParams = {}}) => {

form.loginOptions.forEach(option => {
let readyOption = {...option};
readyOption.url = getLoginUrl(option, extraParams);
readyOption.url = getLoginUrl(option, {}, extraNextParams);
readyOption.label = (
<FormattedMessage
description="Login button label"
Expand Down
4 changes: 2 additions & 2 deletions src/components/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ const isLastStep = (currentStepIndex, submission) => {
return currentStepIndex === submission.steps.length - 1;
};

const getLoginUrl = (loginOption, extraParams = {}) => {
const getLoginUrl = (loginOption, extraParams = {}, extraNextParams = {}) => {
if (loginOption.url === '#') return loginOption.url;

const nextUrl = new URL(window.location.href);

const queryParams = Array.from(nextUrl.searchParams.keys());
Expand All @@ -39,6 +38,7 @@ const getLoginUrl = (loginOption, extraParams = {}) => {
if (!loginUrl.searchParams.has('coSignSubmission')) {
nextUrl.searchParams.set(START_FORM_QUERY_PARAM, '1');
}
Object.entries(extraNextParams).map(([key, value]) => nextUrl.searchParams.set(key, value));

Check warning on line 41 in src/components/utils/index.js

View check run for this annotation

Codecov / codecov/patch

src/components/utils/index.js#L41

Added line #L41 was not covered by tests
loginUrl.searchParams.set('next', nextUrl.toString());
return loginUrl.toString();
};
Expand Down

0 comments on commit aafcf1c

Please sign in to comment.