From 8726a7f931d5c561dc7ff8f6547faad2e087cfeb Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Fri, 5 Dec 2025 11:47:59 -0500 Subject: [PATCH] remove device code ip check and fix edit resource dialog state issue --- server/routers/auth/pollDeviceWebAuth.ts | 10 ------ src/components/ClientResourcesTable.tsx | 2 +- src/components/EditInternalResourceDialog.tsx | 31 ++++++++++++++++--- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/server/routers/auth/pollDeviceWebAuth.ts b/server/routers/auth/pollDeviceWebAuth.ts index ef749c30..9949ab42 100644 --- a/server/routers/auth/pollDeviceWebAuth.ts +++ b/server/routers/auth/pollDeviceWebAuth.ts @@ -125,16 +125,6 @@ export async function pollDeviceWebAuth( }); } - // Check if IP matches - if (!requestIp || !deviceCode.ip || requestIp !== deviceCode.ip) { - return next( - createHttpError( - HttpCode.FORBIDDEN, - "IP address does not match" - ) - ); - } - // Check if userId is set (should be set when verified) if (!deviceCode.userId) { logger.error("Device code is verified but userId is missing", { codeId: deviceCode.codeId }); diff --git a/src/components/ClientResourcesTable.tsx b/src/components/ClientResourcesTable.tsx index 41afbc80..001cb132 100644 --- a/src/components/ClientResourcesTable.tsx +++ b/src/components/ClientResourcesTable.tsx @@ -226,7 +226,7 @@ export default function ClientResourcesTable({ displayText={resourceRow.alias} /> ) : ( - "-" + - ); } }, diff --git a/src/components/EditInternalResourceDialog.tsx b/src/components/EditInternalResourceDialog.tsx index b69d1980..ecb0c925 100644 --- a/src/components/EditInternalResourceDialog.tsx +++ b/src/components/EditInternalResourceDialog.tsx @@ -348,17 +348,38 @@ export default function EditInternalResourceDialog({ } }; - // Set form values only once after initial load const hasInitialized = useRef(false); + const previousResourceId = useRef(null); useEffect(() => { - if (!loadingRolesUsers && !hasInitialized.current) { + if (open) { + const resourceChanged = previousResourceId.current !== resource.id; + + if (resourceChanged) { + form.reset({ + name: resource.name, + mode: resource.mode || "host", + destination: resource.destination || "", + alias: resource.alias ?? null, + roles: [], + users: [], + clients: [] + }); + previousResourceId.current = resource.id; + } + + hasInitialized.current = false; + } + }, [open, resource.id, resource.name, resource.mode, resource.destination, resource.alias, form]); + + useEffect(() => { + if (open && !loadingRolesUsers && !hasInitialized.current) { hasInitialized.current = true; form.setValue("roles", formRoles); form.setValue("users", formUsers); form.setValue("clients", existingClients); } - }, [loadingRolesUsers, formRoles, formUsers, existingClients, form]); + }, [open, loadingRolesUsers, formRoles, formUsers, existingClients, form]); return (