From 665ef08733b82d55a2b5ab3da4689032181cc04b Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Wed, 16 Jul 2025 18:09:17 -0700 Subject: [PATCH] minor fixes for release --- messages/en-US.json | 4 +- server/setup/scriptsSqlite/1.7.0.ts | 11 ++-- .../resources/[resourceId]/general/page.tsx | 57 +++++++++++++++++-- .../settings/sites/[niceId]/SiteInfoCard.tsx | 33 ++++++----- .../[orgId]/settings/sites/create/page.tsx | 43 -------------- src/components/LoginForm.tsx | 11 ++-- 6 files changed, 88 insertions(+), 71 deletions(-) diff --git a/messages/en-US.json b/messages/en-US.json index 58bbd825..16190316 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -1270,5 +1270,7 @@ "createDomainSaveTheseRecords": "Save These Records", "createDomainSaveTheseRecordsDescription": "Make sure to save these DNS records as you will not see them again.", "createDomainDnsPropagation": "DNS Propagation", - "createDomainDnsPropagationDescription": "DNS changes may take some time to propagate across the internet. This can take anywhere from a few minutes to 48 hours, depending on your DNS provider and TTL settings." + "createDomainDnsPropagationDescription": "DNS changes may take some time to propagate across the internet. This can take anywhere from a few minutes to 48 hours, depending on your DNS provider and TTL settings.", + "resourcePortRequired": "Port number is required for non-HTTP resources", + "resourcePortNotAllowed": "Port number should not be set for HTTP resources" } diff --git a/server/setup/scriptsSqlite/1.7.0.ts b/server/setup/scriptsSqlite/1.7.0.ts index e4be598b..f173d12e 100644 --- a/server/setup/scriptsSqlite/1.7.0.ts +++ b/server/setup/scriptsSqlite/1.7.0.ts @@ -11,6 +11,8 @@ export default async function migration() { const db = new Database(location); try { + db.pragma("foreign_keys = OFF"); + db.transaction(() => { db.exec(` CREATE TABLE 'clientSites' ( @@ -99,8 +101,6 @@ export default async function migration() { `); - db.pragma("foreign_keys = OFF"); - db.exec(` CREATE TABLE '__new_sites' ( 'siteId' integer PRIMARY KEY AUTOINCREMENT NOT NULL, @@ -135,8 +135,6 @@ export default async function migration() { ALTER TABLE '__new_sites' RENAME TO 'sites'; `); - db.pragma("foreign_keys = ON"); - db.exec(` ALTER TABLE 'domains' ADD 'type' text; ALTER TABLE 'domains' ADD 'verified' integer DEFAULT 0 NOT NULL; @@ -148,7 +146,10 @@ export default async function migration() { ALTER TABLE 'user' ADD 'twoFactorSetupRequested' integer DEFAULT 0; ALTER TABLE 'resources' DROP COLUMN 'isBaseDomain'; `); - })(); // <-- executes the transaction immediately + })(); + + db.pragma("foreign_keys = ON"); + console.log(`Migrated database schema`); } catch (e) { console.log("Unable to migrate database schema"); diff --git a/src/app/[orgId]/settings/resources/[resourceId]/general/page.tsx b/src/app/[orgId]/settings/resources/[resourceId]/general/page.tsx index 13cb20ba..efda61c3 100644 --- a/src/app/[orgId]/settings/resources/[resourceId]/general/page.tsx +++ b/src/app/[orgId]/settings/resources/[resourceId]/general/page.tsx @@ -122,7 +122,20 @@ export default function GeneralForm() { enabled: z.boolean(), subdomain: z.string().optional(), name: z.string().min(1).max(255), - domainId: z.string().optional() + domainId: z.string().optional(), + proxyPort: z.number().int().min(1).max(65535).optional() + }).refine((data) => { + // For non-HTTP resources, proxyPort should be defined + if (!resource.http) { + return data.proxyPort !== undefined; + } + // For HTTP resources, proxyPort should be undefined + return data.proxyPort === undefined; + }, { + message: !resource.http + ? "Port number is required for non-HTTP resources" + : "Port number should not be set for HTTP resources", + path: ["proxyPort"] }); type GeneralFormValues = z.infer; @@ -133,7 +146,8 @@ export default function GeneralForm() { enabled: resource.enabled, name: resource.name, subdomain: resource.subdomain ? resource.subdomain : undefined, - domainId: resource.domainId || undefined + domainId: resource.domainId || undefined, + proxyPort: resource.proxyPort || undefined }, mode: "onChange" }); @@ -196,7 +210,8 @@ export default function GeneralForm() { enabled: data.enabled, name: data.name, subdomain: data.subdomain, - domainId: data.domainId + domainId: data.domainId, + proxyPort: data.proxyPort } ) .catch((e) => { @@ -222,7 +237,8 @@ export default function GeneralForm() { enabled: data.enabled, name: data.name, subdomain: data.subdomain, - fullDomain: resource.fullDomain + fullDomain: resource.fullDomain, + proxyPort: data.proxyPort }); router.refresh(); @@ -333,6 +349,39 @@ export default function GeneralForm() { )} /> + {!resource.http && ( + <> + ( + + + {t("resourcePortNumber")} + + + + field.onChange( + e.target.value + ? parseInt(e.target.value) + : undefined + ) + } + /> + + + + {t("resourcePortNumberDescription")} + + + )} + /> + + )} + {resource.http && (
diff --git a/src/app/[orgId]/settings/sites/[niceId]/SiteInfoCard.tsx b/src/app/[orgId]/settings/sites/[niceId]/SiteInfoCard.tsx index 31ec7f7f..6094f167 100644 --- a/src/app/[orgId]/settings/sites/[niceId]/SiteInfoCard.tsx +++ b/src/app/[orgId]/settings/sites/[niceId]/SiteInfoCard.tsx @@ -25,32 +25,34 @@ export default function SiteInfoCard({}: SiteInfoCardProps) { } else if (type === "wireguard") { return "WireGuard"; } else if (type === "local") { - return t('local'); + return t("local"); } else { - return t('unknown'); + return t("unknown"); } }; return ( - {t('siteInfo')} + {t("siteInfo")} {(site.type == "newt" || site.type == "wireguard") && ( <> - {t('status')} + + {t("status")} + {site.online ? (
- {t('online')} + {t("online")}
) : (
- {t('offline')} + {t("offline")}
)}
@@ -58,17 +60,22 @@ export default function SiteInfoCard({}: SiteInfoCardProps) { )} - {t('connectionType')} + + {t("connectionType")} + {getConnectionTypeString(site.type)} - - Address - - {site.address?.split("/")[0]} - - + + {env.flags.enableClients && ( + + Address + + {site.address?.split("/")[0]} + + + )}
diff --git a/src/app/[orgId]/settings/sites/create/page.tsx b/src/app/[orgId]/settings/sites/create/page.tsx index e8ea0989..454f609e 100644 --- a/src/app/[orgId]/settings/sites/create/page.tsx +++ b/src/app/[orgId]/settings/sites/create/page.tsx @@ -894,49 +894,6 @@ WantedBy=default.target` )} - -
- - ( - -
- { - form.setValue( - "copied", - e as boolean - ); - }} - /> - -
- -
- )} - /> - - )} diff --git a/src/components/LoginForm.tsx b/src/components/LoginForm.tsx index 04ed25fb..153b7eb7 100644 --- a/src/components/LoginForm.tsx +++ b/src/components/LoginForm.tsx @@ -63,6 +63,7 @@ export default function LoginForm({ redirect, onLogin, idps }: LoginFormProps) { const [error, setError] = useState(null); const [loading, setLoading] = useState(false); + const [securityKeyLoading, setSecurityKeyLoading] = useState(false); const hasIdp = idps && idps.length > 0; const [mfaRequested, setMfaRequested] = useState(false); @@ -98,7 +99,7 @@ export default function LoginForm({ redirect, onLogin, idps }: LoginFormProps) { async function initiateSecurityKeyAuth() { setShowSecurityKeyPrompt(true); - setLoading(true); + setSecurityKeyLoading(true); setError(null); try { @@ -117,7 +118,7 @@ export default function LoginForm({ redirect, onLogin, idps }: LoginFormProps) { // Perform WebAuthn authentication try { const credential = await startAuthentication(options); - + // Verify authentication const verifyRes = await api.post( "/auth/security-key/authenticate/verify", @@ -167,7 +168,7 @@ export default function LoginForm({ redirect, onLogin, idps }: LoginFormProps) { })); } } finally { - setLoading(false); + setSecurityKeyLoading(false); setShowSecurityKeyPrompt(false); } } @@ -432,8 +433,8 @@ export default function LoginForm({ redirect, onLogin, idps }: LoginFormProps) { variant="outline" className="w-full" onClick={initiateSecurityKeyAuth} - loading={loading} - disabled={loading || showSecurityKeyPrompt} + loading={securityKeyLoading} + disabled={securityKeyLoading || showSecurityKeyPrompt} > {t('securityKeyLogin', {