mirror of
https://github.com/logto-io/logto.git
synced 2025-03-24 22:41:28 -05:00
fix(console): update terms of use (#1122)
This commit is contained in:
parent
65f9a6fa39
commit
9262a6f3be
3 changed files with 17 additions and 3 deletions
|
@ -24,7 +24,7 @@ const TermsForm = () => {
|
|||
<div className={styles.title}>{t('sign_in_exp.terms_of_use.title')}</div>
|
||||
<FormField title="admin_console.sign_in_exp.terms_of_use.enable">
|
||||
<Switch
|
||||
{...register('termsOfUse.enabled', { required: true })}
|
||||
{...register('termsOfUse.enabled')}
|
||||
label={t('sign_in_exp.terms_of_use.description')}
|
||||
/>
|
||||
</FormField>
|
||||
|
|
|
@ -67,10 +67,24 @@ describe('terms of use', () => {
|
|||
}
|
||||
);
|
||||
|
||||
test.each([null, '', ' \t\n\r', 'non-url'])('%p should fail', async (contentUrl) => {
|
||||
test.each([null, ' \t\n\r', 'non-url'])('%p should fail', async (contentUrl) => {
|
||||
const signInExperience = { termsOfUse: { ...mockTermsOfUse, enabled: false, contentUrl } };
|
||||
await expectPatchResponseStatus(signInExperience, 400);
|
||||
});
|
||||
|
||||
test('should allow empty contentUrl if termsOfUse is disabled', async () => {
|
||||
const signInExperience = {
|
||||
termsOfUse: { ...mockTermsOfUse, enabled: false, contentUrl: '' },
|
||||
};
|
||||
await expectPatchResponseStatus(signInExperience, 200);
|
||||
});
|
||||
|
||||
test('should not allow empty contentUrl if termsOfUse is enabled', async () => {
|
||||
const signInExperience = {
|
||||
termsOfUse: { ...mockTermsOfUse, enabled: true, contentUrl: '' },
|
||||
};
|
||||
await expectPatchResponseStatus(signInExperience, 400);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ export type Branding = z.infer<typeof brandingGuard>;
|
|||
|
||||
export const termsOfUseGuard = z.object({
|
||||
enabled: z.boolean(),
|
||||
contentUrl: z.string().url().optional(),
|
||||
contentUrl: z.string().url().optional().or(z.literal('')),
|
||||
});
|
||||
|
||||
export type TermsOfUse = z.infer<typeof termsOfUseGuard>;
|
||||
|
|
Loading…
Add table
Reference in a new issue