Dingtian web password: set the admin's chosen password, verified
Fix two bugs found running the real assign flow: the saved web password didn't match the device (login stayed admin/admin), and the UDP2 warning never reached the admin. Web password: - Split the conflated field into webPassword (the DESIRED login; blank -> auto-generate) and webPasswordCurrent (the device's EXISTING password used as the old cred, default admin). Before, an admin typing a desired password made harden send it as the old cred -> rotation failed -> but the DB still saved the typed value, so it claimed a password the device never accepted. - harden() now rotates current -> desired, VERIFIES by re-authenticating with the new password, and only returns secrets.webPassword on success (else a warning, nothing saved). Stores webPasswordCurrent for future re-runs. - assign strips the typed webPassword/webPasswordCurrent and persists only the verified secret -- the DB never claims an unapplied password. Warnings to the UI: - assignDevice returns warnings[]; SetupWizard shows them in an amber "saved, but action needed" banner per category. This is how the admin learns the firmware wouldn't disable UDP2 (finish in the device web UI). Verified on hardware: after harden the device rejects admin/admin and accepts the chosen password; the UDP2 warning surfaces.
This commit is contained in:
@@ -162,6 +162,15 @@ export async function setupRoutes(app: FastifyInstance, db: Db): Promise<void> {
|
||||
|
||||
const id = randomUUID();
|
||||
const fullConfig: Record<string, unknown> = { ...config };
|
||||
// The web password the admin typed is a DESIRED value, not a stored fact:
|
||||
// it's passed to the driver (via create(config) below) as the rotation
|
||||
// target, but we do NOT persist it from the form. Only harden()'s VERIFIED
|
||||
// secrets.webPassword gets saved — otherwise a failed rotation would leave
|
||||
// the DB claiming a password the device never accepted (login stays old).
|
||||
delete fullConfig.webPassword;
|
||||
// webPasswordCurrent is an input-only credential (the OLD password used to
|
||||
// authorize the change) — never persist it as typed.
|
||||
delete fullConfig.webPasswordCurrent;
|
||||
// Residual-risk warnings from device hardening (shown to the admin; the
|
||||
// save still succeeds — these are "configured, but note X" advisories).
|
||||
const hardenWarnings: string[] = [];
|
||||
|
||||
Reference in New Issue
Block a user