Fix credential auth optional password (#1009)

This commit is contained in:
ZacharyZcR
2026-07-10 08:03:14 +08:00
committed by GitHub
parent 37560fa133
commit 6b98b86969
8 changed files with 79 additions and 14 deletions
+11
View File
@@ -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>
+3 -3
View File
@@ -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();
});
+2 -1
View File
@@ -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