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

fix(experience): add sso form mode context provider for identifier sign-in/register pages #6482

Merged
merged 1 commit into from
Aug 21, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,13 @@ describe('<IdentifierRegisterForm />', () => {
mockSsoConnectors
);
const emailInput = container.querySelector('input[name="id"]');
const termsButton = getByText('description.agree_with_terms');

assert(emailInput, new Error('username input not found'));

act(() => {
fireEvent.change(emailInput, { target: { value: email } });
fireEvent.click(termsButton);
});

await waitFor(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,24 @@ const IdentifierRegisterForm = ({ className, autoFocus, signUpMethods }: Props)

setIdentifierInputValue({ type, value });

if (showSingleSignOnForm) {
await navigateToSingleSignOn();
if (
agreeToTermsPolicy &&
agreeToTermsPolicy !== AgreeToTermsPolicy.Automatic &&
!(await termsValidation())
) {
return;
}

if (!(await termsValidation())) {
if (showSingleSignOnForm) {
await navigateToSingleSignOn();
return;
}

await onSubmit(type, value);
})(event);
},
[
agreeToTermsPolicy,
clearErrorMessage,
handleSubmit,
navigateToSingleSignOn,
Expand Down
5 changes: 4 additions & 1 deletion packages/experience/src/pages/IdentifierRegister/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
import { Navigate } from 'react-router-dom';

import FocusedAuthPageLayout from '@/Layout/FocusedAuthPageLayout';
import SingleSignOnFormModeContextProvider from '@/Providers/SingleSignOnFormModeContextProvider';
import IdentifierRegisterForm from '@/components/IdentifierRegisterForm';
import { useSieMethods } from '@/hooks/use-sie';
import { identifierInputDescriptionMap } from '@/utils/form';
Expand Down Expand Up @@ -36,7 +37,9 @@ const IdentifierRegister = () => {
text: 'description.all_account_creation_options',
}}
>
<IdentifierRegisterForm signUpMethods={signUpMethods} />
<SingleSignOnFormModeContextProvider>
<IdentifierRegisterForm signUpMethods={signUpMethods} />
</SingleSignOnFormModeContextProvider>
</FocusedAuthPageLayout>
);
};
Expand Down
13 changes: 8 additions & 5 deletions packages/experience/src/pages/IdentifierSignIn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { Navigate } from 'react-router-dom';

import FocusedAuthPageLayout from '@/Layout/FocusedAuthPageLayout';
import SingleSignOnFormModeContextProvider from '@/Providers/SingleSignOnFormModeContextProvider';
import IdentifierSignInForm from '@/components/IdentifierSignInForm';
import PasswordSignInForm from '@/components/PasswordSignInForm';
import { identifierInputDescriptionMap } from '@/utils/form';
Expand Down Expand Up @@ -43,11 +44,13 @@ const IdentifierSignIn = () => {
text: 'description.all_sign_in_options',
}}
>
{isPasswordOnly ? (
<PasswordSignInForm signInMethods={signInMethods.map(({ identifier }) => identifier)} />
) : (
<IdentifierSignInForm signInMethods={signInMethods} />
)}
<SingleSignOnFormModeContextProvider>
{isPasswordOnly ? (
<PasswordSignInForm signInMethods={signInMethods.map(({ identifier }) => identifier)} />
) : (
<IdentifierSignInForm signInMethods={signInMethods} />
)}
</SingleSignOnFormModeContextProvider>
</FocusedAuthPageLayout>
);
};
Expand Down
Loading