mirror of
https://github.com/logto-io/logto.git
synced 2025-04-07 23:01:25 -05:00
fix(experience): add sso form mode context provider for identifier sign-in/register pages (#6482)
This commit is contained in:
parent
b8b77526e4
commit
0ec8510789
4 changed files with 22 additions and 9 deletions
|
@ -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(() => {
|
||||
|
|
|
@ -71,12 +71,16 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -84,6 +88,7 @@ const IdentifierRegisterForm = ({ className, autoFocus, signUpMethods }: Props)
|
|||
})(event);
|
||||
},
|
||||
[
|
||||
agreeToTermsPolicy,
|
||||
clearErrorMessage,
|
||||
handleSubmit,
|
||||
navigateToSingleSignOn,
|
||||
|
|
|
@ -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';
|
||||
|
@ -36,7 +37,9 @@ const IdentifierRegister = () => {
|
|||
text: 'description.all_account_creation_options',
|
||||
}}
|
||||
>
|
||||
<IdentifierRegisterForm signUpMethods={signUpMethods} />
|
||||
<SingleSignOnFormModeContextProvider>
|
||||
<IdentifierRegisterForm signUpMethods={signUpMethods} />
|
||||
</SingleSignOnFormModeContextProvider>
|
||||
</FocusedAuthPageLayout>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -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';
|
||||
|
@ -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>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue