Hide register link when registration is disabled

This commit is contained in:
Erwan Leboucher committed 2026-07-13 19:55:20 +02:00
1 parent d8938a625d
commit 9e80f56eae
1 file changed
+10 -5
+10 -5
View File
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
import { Box, Text, color } from 'folds';
import { Link, useSearchParams } from 'react-router-dom';
import { SSOAction } from '$types/matrix-sdk';
import { useAuthFlows } from '$hooks/useAuthFlows';
import { RegisterFlowStatus, useAuthFlows } from '$hooks/useAuthFlows';
import { useAuthServer } from '$hooks/useAuthServer';
import { useParsedLoginFlows } from '$hooks/useParsedLoginFlows';
import { getLoginPath, getRegisterPath, withSearchParam } from '$pages/pathUtils';
@@ -38,7 +38,7 @@ export function Login() {
const server = useAuthServer();
const { hashRouter } = useClientConfig();
const { hideUsernamePasswordFields } = useClientConfig();
const { loginFlows } = useAuthFlows();
const { loginFlows, registerFlows } = useAuthFlows();
const [searchParams] = useSearchParams();
const loginSearchParams = useLoginSearchParams(searchParams);
const ssoRedirectUrl = usePathWithOrigin(getLoginPath(server));
@@ -61,6 +61,9 @@ export function Login() {
? withSearchParam(getRegisterPath(server), { addAccount: '1' })
: getRegisterPath(server);
const registrationUnavailable =
registerFlows.status === RegisterFlowStatus.RegistrationDisabled && !parsedFlows.sso;
return (
<Box direction="Column" gap="500">
<Text size="H2" priority="400">
@@ -98,9 +101,11 @@ export function Login() {
<span data-spacing-node />
</>
)}
<Text align="Center">
Do not have an account? <Link to={registerUrl}>Register</Link>
</Text>
{!registrationUnavailable && (
<Text align="Center">
Do not have an account? <Link to={registerUrl}>Register</Link>
</Text>
)}
</Box>
);
}