diff --git a/.changeset/hide-register-when-disabled.md b/.changeset/hide-register-when-disabled.md new file mode 100644 index 0000000000..20e558b331 --- /dev/null +++ b/.changeset/hide-register-when-disabled.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Hide the "Register" link on the login page when the homeserver has registration disabled and offers no SSO to register through, so you are no longer sent to a dead-end registration page. diff --git a/src/app/pages/auth/login/Login.tsx b/src/app/pages/auth/login/Login.tsx index 2aa6fc8a5b..8598a25a04 100644 --- a/src/app/pages/auth/login/Login.tsx +++ b/src/app/pages/auth/login/Login.tsx @@ -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 ( @@ -98,9 +101,11 @@ export function Login() { )} - - Do not have an account? Register - + {!registrationUnavailable && ( + + Do not have an account? Register + + )} ); }