mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-26 09:02:11 +03:00
fix(cli): preserve existing admin password during setup (#11522)
Validated in a combined 10-PR batch worktree off release/v3.8.51 tip. Fixes #11494. - Focused test: tests/unit/cli-setup-command.test.ts — 10/10 pass - typecheck:core, file-size, changelog-integrity, complexity, cognitive-complexity gates — all OK - Full-repo lint: 503 pre-existing problems confirmed identical on the pure release/v3.8.51 tip (isolated probe) — unrelated to this diff (bin/cli only) ⚠️ base-red inherited: #11449 Thanks for preventing INITIAL_PASSWORD from silently overwriting an operator's already-set admin password.
This commit is contained in:
@@ -24,9 +24,9 @@ function wantsProviderSetup(opts) {
|
||||
return opts.addProvider || Boolean(opts.provider) || Boolean(opts.apiKey);
|
||||
}
|
||||
|
||||
async function resolvePassword(opts, prompt, nonInteractive) {
|
||||
if (opts.password) return opts.password;
|
||||
if (process.env.INITIAL_PASSWORD) return process.env.INITIAL_PASSWORD;
|
||||
async function resolvePassword(opts, prompt, nonInteractive, settings) {
|
||||
if (opts.password !== undefined) return opts.password;
|
||||
if (!settings.password && process.env.INITIAL_PASSWORD) return process.env.INITIAL_PASSWORD;
|
||||
if (nonInteractive) return "";
|
||||
|
||||
const answer = await prompt.ask("Set an admin password now? [y/N]", "N");
|
||||
@@ -41,9 +41,9 @@ async function resolvePassword(opts, prompt, nonInteractive) {
|
||||
}
|
||||
|
||||
async function setupPassword(db, opts, prompt, nonInteractive) {
|
||||
const password = await resolvePassword(opts, prompt, nonInteractive);
|
||||
const settings = getSettings(db);
|
||||
const password = await resolvePassword(opts, prompt, nonInteractive, settings);
|
||||
if (!password) {
|
||||
const settings = getSettings(db);
|
||||
if (!settings.password) {
|
||||
updateSettings(db, { requireLogin: false });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user