Skip to content

Commit 21a2ea7

Browse files
authored
fix(console): update captcha backlink and always show captcha toggle (#7396)
1 parent d46824a commit 21a2ea7

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

.changeset/perfect-phones-relax.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@logto/console": patch
3+
---
4+
5+
always show enable CAPTCHA toggle
6+
7+
Even if there is no CAPTCHA provider, the toggle will be shown but disabled.
8+
9+
Also the back link of the captcha details page is changed to `/security/captcha`.

packages/console/src/pages/CaptchaDetails/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function CaptchaDetails() {
7171

7272
return (
7373
<DetailsPage
74-
backLink="/security"
74+
backLink="/security/captcha"
7575
backLinkTitle="security.captcha_details.back_to_security"
7676
isLoading={isLoading}
7777
error={error}

packages/console/src/pages/Security/Captcha/EnableCaptcha/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import { type RequestError } from '@/hooks/use-api';
1010

1111
import styles from './index.module.scss';
1212

13-
function EnableCaptcha() {
13+
type Props = {
14+
// eslint-disable-next-line react/boolean-prop-naming
15+
readonly disabled?: boolean;
16+
};
17+
18+
function EnableCaptcha({ disabled }: Props) {
1419
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
1520
const { register, reset } = useFormContext<CaptchaPolicy>();
1621
const { data, isLoading } = useSWR<SignInExperience, RequestError>('api/sign-in-exp');
@@ -32,6 +37,7 @@ function EnableCaptcha() {
3237
<Switch
3338
label={t('security.bot_protection.enable_captcha_description')}
3439
{...register('enabled')}
40+
disabled={disabled}
3541
/>
3642
</div>
3743
</FormField>

packages/console/src/pages/Security/Captcha/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ function Captcha() {
105105
{t('security.bot_protection.captcha.placeholder')}
106106
</div>
107107
{data && !isFreeTenant ? (
108-
<>
109-
<CaptchaCard captchaProvider={data} />
110-
<EnableCaptcha />
111-
</>
108+
<CaptchaCard captchaProvider={data} />
112109
) : (
113110
<Button
114111
title="security.bot_protection.captcha.add"
@@ -119,6 +116,7 @@ function Captcha() {
119116
}}
120117
/>
121118
)}
119+
<EnableCaptcha disabled={isFreeTenant || !data} />
122120
</FormField>
123121
</FormCard>
124122
</DetailsForm>

0 commit comments

Comments
 (0)