diff --git a/src/components/FormStart/index.js b/src/components/FormStart/index.js index 70acd9940..f8f771f90 100644 --- a/src/components/FormStart/index.js +++ b/src/components/FormStart/index.js @@ -124,7 +124,7 @@ const FormStart = ({form, submission, onFormStart, onDestroySession, initialData )} diff --git a/src/components/FormStart/tests.spec.js b/src/components/FormStart/tests.spec.js index 85a4fca25..bed48cc90 100644 --- a/src/components/FormStart/tests.spec.js +++ b/src/components/FormStart/tests.spec.js @@ -112,6 +112,6 @@ it('Form start page with initial_data_reference', async () => { const loginLink = await screen.findByRole('link', {name: 'Login with DigiD'}); expect(loginLink).toHaveAttribute( 'href', - 'https://openforms.nl/auth/form-name/digid/start?initial_data_reference=1234&next=http%3A%2F%2Flocalhost%2F%3F_start%3D1' + 'https://openforms.nl/auth/form-name/digid/start?next=http%3A%2F%2Flocalhost%2F%3F_start%3D1%26initial_data_reference%3D1234' ); }); diff --git a/src/components/LoginOptions/index.js b/src/components/LoginOptions/index.js index 187bd6f11..32a742150 100644 --- a/src/components/LoginOptions/index.js +++ b/src/components/LoginOptions/index.js @@ -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 = []; @@ -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 = ( { 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()); @@ -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)); loginUrl.searchParams.set('next', nextUrl.toString()); return loginUrl.toString(); };