Fix: Support camelCase keyPassword in JSON host import #384
@@ -1412,7 +1412,7 @@ router.post(
|
||||
hostData.authType === "credential" ? hostData.credentialId : null,
|
||||
key: hostData.authType === "key" ? hostData.key : null,
|
||||
key_password:
|
||||
hostData.authType === "key" ? hostData.key_password : null,
|
||||
hostData.authType === "key" ? hostData.keyPassword : null,
|
||||
keyType:
|
||||
|
|
||||
hostData.authType === "key" ? hostData.keyType || "auto" : null,
|
||||
pin: hostData.pin || false,
|
||||
|
||||
Reference in New Issue
Block a user
While this change correctly adds support for
keyPassword, it removes the existing support forkey_password. This could be a breaking change for any clients that might be using the snake_case version.To ensure backward compatibility and make the API more robust, it would be better to support both formats. You can achieve this by checking for
keyPasswordfirst and then falling back tokey_passwordif the former is not present. This approach is also used elsewhere in the codebase (e.g., inresolveHostCredentials).Before:
After:
The fix ensures that JSON imports with the following structure work correctly: