From 130b4f5cc39478dd90e10f24c5fb0f0ce90420bc Mon Sep 17 00:00:00 2001 From: qtchaos <72168435+qtchaos@users.noreply.github.com> Date: Sun, 25 Feb 2024 21:31:08 +0200 Subject: [PATCH] feat: disable creating account when server is not set --- src/assets/locales/en.json | 2 + src/pages/parts/auth/TrustBackendPart.tsx | 72 ++++++++++++++--------- 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json index c6a43875..55922380 100644 --- a/src/assets/locales/en.json +++ b/src/assets/locales/en.json @@ -55,6 +55,8 @@ "text": "Did you configure it correctly?", "title": "Failed to reach server" }, + "noHostTitle": "Server not configured!", + "noHost": "The server has not been configured, therefore you cannot create an account", "host": "You are connecting to <0>{{hostname}} - please confirm you trust it before making an account", "no": "Go back", "title": "Do you trust this server?", diff --git a/src/pages/parts/auth/TrustBackendPart.tsx b/src/pages/parts/auth/TrustBackendPart.tsx index 0d71e403..16c16c66 100644 --- a/src/pages/parts/auth/TrustBackendPart.tsx +++ b/src/pages/parts/auth/TrustBackendPart.tsx @@ -23,7 +23,7 @@ export function TrustBackendPart(props: TrustBackendPartProps) { const navigate = useNavigate(); const backendUrl = useBackendUrl(); const hostname = useMemo( - () => (backendUrl ? new URL(backendUrl).hostname : ""), + () => (backendUrl ? new URL(backendUrl).hostname : undefined), [backendUrl], ); const result = useAsync(() => { @@ -54,38 +54,52 @@ export function TrustBackendPart(props: TrustBackendPartProps) { return ( } > - - - + {hostname ? ( + + + + ) : ( +

{t("auth.trust.noHost")}

+ )}
-
- {cardContent} -
- - - - -

- - . - -

+ {hostname ? ( + <> +
+ {cardContent} +
+ + + + +

+ + . + +

+ + ) : ( + + + + )}
); }