mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-27 20:36:27 -08:00
Hide register link when registration is disabled
This commit is contained in:
1 file changed
+10
-5
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user