mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-15 21:03:47 +00:00
Fix credential auth optional password (#1009)
This commit is contained in:
@@ -592,6 +592,17 @@ export function HostEditor({
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex flex-col gap-1.5">
|
||||
<label className="text-[10px] font-bold uppercase tracking-widest text-muted-foreground">
|
||||
{t("hosts.password")} ({t("common.optional")})
|
||||
</label>
|
||||
<PasswordInput
|
||||
className="h-8 text-xs pr-8"
|
||||
placeholder="••••••••"
|
||||
value={form.password}
|
||||
onChange={(e) => setField("password", e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -45,19 +45,19 @@ describe("buildHostEditorPayload auth field isolation", () => {
|
||||
expect(payload.password).toBe("newpass");
|
||||
});
|
||||
|
||||
it("only sends the credentialId when authType is credential", () => {
|
||||
it("sends credentialId and optional password when authType is credential", () => {
|
||||
const form = {
|
||||
...createHostEditorForm(null),
|
||||
authType: "credential" as const,
|
||||
credentialId: "7",
|
||||
password: "leftover",
|
||||
password: "host-specific-password",
|
||||
key: "leftover-key",
|
||||
};
|
||||
|
||||
const payload = buildHostEditorPayload(form, sshOnly);
|
||||
|
||||
expect(payload.credentialId).toBe(7);
|
||||
expect(payload.password).toBeNull();
|
||||
expect(payload.password).toBe("host-specific-password");
|
||||
expect(payload.key).toBeNull();
|
||||
});
|
||||
|
||||
|
||||
@@ -273,7 +273,8 @@ export function buildHostEditorPayload(
|
||||
pin: form.pin,
|
||||
authType: form.authType,
|
||||
useWarpgate: form.useWarpgate,
|
||||
password: usesPassword || usesKey ? form.password || null : null,
|
||||
password:
|
||||
usesPassword || usesKey || usesCredential ? form.password || null : null,
|
||||
key: usesKey
|
||||
? form.key === "existing_key"
|
||||
? undefined
|
||||
|
||||
Reference in New Issue
Block a user