Browse Source

feat: disable creating account when server is not set

pull/938/head
qtchaos 1 year ago
parent
commit
130b4f5cc3
No known key found for this signature in database
GPG Key ID: 7DA98B2B9EF06A90
  1. 2
      src/assets/locales/en.json
  2. 18
      src/pages/parts/auth/TrustBackendPart.tsx

2
src/assets/locales/en.json

@ -55,6 +55,8 @@ @@ -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}}</0> - please confirm you trust it before making an account",
"no": "Go back",
"title": "Do you trust this server?",

18
src/pages/parts/auth/TrustBackendPart.tsx

@ -23,7 +23,7 @@ export function TrustBackendPart(props: TrustBackendPartProps) { @@ -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,9 +54,10 @@ export function TrustBackendPart(props: TrustBackendPartProps) { @@ -54,9 +54,10 @@ export function TrustBackendPart(props: TrustBackendPartProps) {
return (
<LargeCard>
<LargeCardText
title={t("auth.trust.title")}
title={hostname ? t("auth.trust.title") : t("auth.trust.noHostTitle")}
icon={<Icon icon={Icons.CIRCLE_EXCLAMATION} />}
>
{hostname ? (
<Trans
i18nKey="auth.trust.host"
values={{
@ -65,8 +66,13 @@ export function TrustBackendPart(props: TrustBackendPartProps) { @@ -65,8 +66,13 @@ export function TrustBackendPart(props: TrustBackendPartProps) {
>
<span className="text-white" />
</Trans>
) : (
<p>{t("auth.trust.noHost")}</p>
)}
</LargeCardText>
{hostname ? (
<>
<div className="border border-authentication-border rounded-xl px-4 py-8 flex flex-col items-center space-y-2 my-8">
{cardContent}
</div>
@ -86,6 +92,14 @@ export function TrustBackendPart(props: TrustBackendPartProps) { @@ -86,6 +92,14 @@ export function TrustBackendPart(props: TrustBackendPartProps) {
<MwLink to="/login">.</MwLink>
</Trans>
</p>
</>
) : (
<LargeCardButtons>
<Button theme="purple" onClick={() => navigate("/")}>
{t("auth.trust.no")}
</Button>
</LargeCardButtons>
)}
</LargeCard>
);
}

Loading…
Cancel
Save