Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hide-register-when-disabled.md
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 10 additions & 5 deletions src/app/pages/auth/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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));
Expand All @@ -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">
Expand Down Expand Up @@ -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>
);
}
Loading