mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-28 07:46:36 +00:00
remove device code ip check and fix edit resource dialog state issue
This commit is contained in:
@@ -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)
|
// Check if userId is set (should be set when verified)
|
||||||
if (!deviceCode.userId) {
|
if (!deviceCode.userId) {
|
||||||
logger.error("Device code is verified but userId is missing", { codeId: deviceCode.codeId });
|
logger.error("Device code is verified but userId is missing", { codeId: deviceCode.codeId });
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ export default function ClientResourcesTable({
|
|||||||
displayText={resourceRow.alias}
|
displayText={resourceRow.alias}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span>"-"</span>
|
<span>-</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -348,17 +348,38 @@ export default function EditInternalResourceDialog({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set form values only once after initial load
|
|
||||||
const hasInitialized = useRef(false);
|
const hasInitialized = useRef(false);
|
||||||
|
const previousResourceId = useRef<number | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
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;
|
hasInitialized.current = true;
|
||||||
form.setValue("roles", formRoles);
|
form.setValue("roles", formRoles);
|
||||||
form.setValue("users", formUsers);
|
form.setValue("users", formUsers);
|
||||||
form.setValue("clients", existingClients);
|
form.setValue("clients", existingClients);
|
||||||
}
|
}
|
||||||
}, [loadingRolesUsers, formRoles, formUsers, existingClients, form]);
|
}, [open, loadingRolesUsers, formRoles, formUsers, existingClients, form]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Credenza
|
<Credenza
|
||||||
@@ -378,8 +399,8 @@ export default function EditInternalResourceDialog({
|
|||||||
users: [],
|
users: [],
|
||||||
clients: []
|
clients: []
|
||||||
});
|
});
|
||||||
// Reset initialization flag so form can re-initialize with fresh data when reopened
|
// Reset previous resource ID to ensure clean state on next open
|
||||||
hasInitialized.current = false;
|
previousResourceId.current = null;
|
||||||
}
|
}
|
||||||
setOpen(open);
|
setOpen(open);
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user