Share the saved admin password across ESP32 management services

Use the committed node credential for setup WiFi, WebConfig and browser OTA. Add persistent ESP32 WiFi Companion management credentials without changing preferences layouts, revoke stale browser sessions on rotation, retain scoped save receipts, and coordinate credential changes with flash uploads. Keep external-service credentials and trusted TCP protocol compatibility independent. Update live join QR codes, failure handling and documentation.

Validated 51 native cases, 158 related host and browser methods, and serial Full V4 Companion, Station G3 Repeater, ESP32-C6 Room Server and V4 Sensor firmware builds.
This commit is contained in:
mikecarper committed 2026-10-18 13:09:48 -07:00
1 parent a6a3cb5ebc
commit cd02e55824
58 files changed
+5749 -2439

No files matched your search

+165 -47
View File
@@ -226,12 +226,13 @@ body.tab-cli{padding-bottom:0}
aria-label="Open console">&gt;_</button>
</header>
<main>
<div id="login-note" class="note hide" role="status"></div>
<!-- ============ LOGIN ============ -->
<section id="v-login" class="hide">
<div class="card">
<h2>Admin login</h2>
<p style="font-size:13.5px;color:var(--mut);margin-bottom:12px">Enter this node's admin password (the same one used for remote CLI admin).</p>
<p style="font-size:13.5px;color:var(--mut);margin-bottom:12px">Enter this node's admin password.</p>
<form id="login-form">
<div class="f"><label for="login-pwd">Password</label>
<input type="password" id="login-pwd" autocomplete="current-password" autofocus></div>
@@ -287,10 +288,10 @@ body.tab-cli{padding-bottom:0}
</div>
<div class="card password-card">
<h2>Admin password</h2>
<p style="font-size:13.5px;color:var(--mut);margin-bottom:12px">Replaces the factory password. It is used to sign in here later and to administer the node remotely over the mesh.</p>
<p style="font-size:13.5px;color:var(--mut);margin-bottom:12px">One admin password for this node's configuration page, firmware uploads, and protected setup WiFi.</p>
<div class="f"><label>New password</label>
<input type="password" data-k="password" maxlength="15" autocomplete="new-password">
<div class="hint">Maximum 15 characters.</div></div>
<div class="hint">Maximum 15 UTF-8 bytes. Use 8-15 printable ASCII characters to also protect the setup WiFi.</div></div>
<div class="f"><label>Confirm password</label>
<input type="password" data-cfm="password" maxlength="15" autocomplete="new-password"></div>
</div>
@@ -375,7 +376,7 @@ body.tab-cli{padding-bottom:0}
</div>
<div class="card password-card">
<h2>Admin password</h2>
<div class="note">Signs in here and authenticates remote admin commands over the mesh. Leave blank to keep the current password. Maximum 15 characters.</div>
<div class="note">Used for this node's configuration page and firmware uploads. Leave blank to keep the current password. Maximum 15 UTF-8 bytes. Use 8-15 printable ASCII characters to also protect the setup WiFi with this password.</div>
<div class="f"><label>New password</label>
<input type="password" data-k="password" maxlength="15" autocomplete="new-password"></div>
<div class="f"><label>Confirm password</label>
@@ -678,6 +679,7 @@ function shortVer(){
function api(path,opts){
opts=opts||{};
var authEpoch=loginEpoch;
if(!opts.cache)opts.cache="no-store"; // iOS caches plain-HTTP API GETs across sessions
if(opts.timeout&&window.AbortController){
// The CNA sheet can leave a fetch hanging forever on a dead connection;
@@ -686,7 +688,7 @@ function api(path,opts){
setTimeout(function(){ctl.abort()},opts.timeout);
}
return fetch(path,opts).then(function(r){
if(r.status===401){showLogin();throw new Error("auth")}
if(r.status===401){if(authEpoch===loginEpoch)showLogin();var authError=new Error("auth");authError.status=401;authError.staleAuth=authEpoch!==loginEpoch;throw authError}
// An error response need not carry JSON -- a bare 404 from handleNotFound
// has an empty body. Letting the parse failure escape would strip the HTTP
// status off the error and leave callers unable to tell "no such endpoint"
@@ -790,22 +792,69 @@ function boot(){
function show(v){["#v-login","#v-wizard","#v-app"].forEach(function(id){$(id).classList.add("hide")});$(v).classList.remove("hide");
document.body.classList.remove("tab-cli"); // re-armed by the tab click when the CLI is the one shown
updateSaveBar()}
function showLogin(){show("#v-login")}
function showLogin(note){
st.authed=false;
if(note!==undefined){$("#login-note").textContent=note;$("#login-note").classList.toggle("hide",!note)}
show("#v-login");
}
/* ---------- login ---------- */
var loginEpoch=0,loginResume=null;
function loginRequest(password){
return fetch("/api/login",{method:"POST",headers:{"Content-Type":"application/json"},
body:JSON.stringify({password:password})})
.then(function(r){return r.json().then(function(j){return{s:r.status,j:j}})});
}
$("#login-form").addEventListener("submit",function(ev){
ev.preventDefault();
var btn=$("#login-btn");btn.disabled=true;$("#login-err").textContent="";
fetch("/api/login",{method:"POST",headers:{"Content-Type":"application/json"},
body:JSON.stringify({password:$("#login-pwd").value})})
.then(function(r){return r.json().then(function(j){return{s:r.status,j:j}})})
var btn=$("#login-btn");if(btn.disabled)return;
var epoch=++loginEpoch,password=$("#login-pwd").value;
$("#login-pwd").value="";btn.disabled=true;$("#login-err").textContent="";
loginRequest(password)
.then(function(x){
if(epoch!==loginEpoch)return;
btn.disabled=false;
if(x.s===200){st.authed=true;$("#login-pwd").value="";if(st.mode==="setup"){showWizard()}else{enterApp()}}
if(x.s===200){
st.authed=true;
var resume=loginResume;loginResume=null;
if(resume)resume();else if(st.mode==="setup"){showWizard()}else{enterApp()}
}
else $("#login-err").textContent=x.j.error||"login failed";
}).catch(function(){btn.disabled=false;$("#login-err").textContent="connection error"});
}).catch(function(){if(epoch===loginEpoch){btn.disabled=false;$("#login-err").textContent="connection error"}});
password="";
});
function doLogout(){post("/api/logout",{}).then(function(){st.authed=false;showLogin()}).catch(function(){})}
function doLogout(){post("/api/logout",{}).then(function(){++loginEpoch;loginResume=null;showLogin("")}).catch(function(){})}
// A password save revokes the old session. Keep only a single in-memory login
// attempt, then let the ordinary form resume the same result read if needed.
// Never retry a settings/terminal POST: it may already have executed.
function reauthenticateOnce(auth,note,resume,keepView){
var view=auth&&auth.view||($("#v-wizard").classList.contains("hide")?"#v-app":"#v-wizard");
var epoch=++loginEpoch,password=auth&&!auth.attempted?auth.password:"";
if(auth){auth.attempted=true;auth.password="";auth.view=view;auth.restored=false}
st.authed=false;clearInterval(st.statsTimer);st.statsTimer=0;
$("#login-note").textContent=note;$("#login-note").classList.remove("hide");
$("#login-pwd").value="";$("#login-err").textContent="";
function restored(){if(auth)auth.restored=true;if(!keepView)show(view);if(resume)resume()}
loginResume=restored;
if(!keepView)showLogin(note);
var btn=$("#login-btn");btn.disabled=!!password;
if(!password)return;
loginRequest(password).then(function(x){
if(epoch!==loginEpoch)return;
btn.disabled=false;
if(x.s===200){st.authed=true;loginResume=null;restored()}
else $("#login-err").textContent=x.j.error||"Sign in with the current admin password";
}).catch(function(){if(epoch===loginEpoch){btn.disabled=false;$("#login-err").textContent="Couldn't sign in automatically. Enter the current admin password."}});
password="";
}
function forgetSubmittedPassword(submitted){
var password=submitted&&submitted.password;
if(!password)return;
if(st.dirty.password===password)delete st.dirty.password;
$$('[data-k="password"],[data-cfm="password"]').forEach(function(el){if(el.value===password)el.value=""});
delete submitted.password;
}
/* ---------- config load / bind ---------- */
function cfgVal(k){ // map a `set` key to its current value string, from st.cfg
@@ -1221,6 +1270,7 @@ function chipFor(el,ok,msg){
lab.querySelector("label").appendChild(c);
}
function saveChanges(extra,cb){
$("#login-note").textContent="";$("#login-note").classList.add("hide");
var setmap={};
// Clear old presets first, then assign new presets, then apply their fields.
// This lets an operator move a unique preset to an empty slot in one save.
@@ -1236,8 +1286,9 @@ function saveChanges(extra,cb){
if((extra&&extra.reboot)||("wifi.ssid" in setmap)||("wifi.pwd" in setmap)||("espnow.channel" in setmap)||("bluetooth.mac" in setmap)||("bluetooth.stealth" in setmap))body.reboot=true;
if(Object.keys(setmap).length===0&&!body.reboot){toast("Nothing to save");return}
var reqid=mkReqId();body.reqid=reqid;
var auth={password:setmap.password||"",attempted:false,view:$("#v-wizard").classList.contains("hide")?"#v-app":"#v-wizard"};
$("#save-btn").disabled=true;
post("/api/config",body).then(function(){pollResult(cb,0,0,true,reqid,setmap)})
post("/api/config",body).then(function(){pollResult(cb,0,0,true,reqid,setmap,auth)})
.catch(function(e){
if(e.message==="auth"){$("#save-btn").disabled=false;if(cb)cb(null,false);return}
if(e.status===400||e.status===413){
@@ -1258,14 +1309,14 @@ function saveChanges(extra,cb){
return;
}
if(e.status===409){
if(e.reqid===reqid){pollResult(cb,0,0,true,reqid,setmap);return}
if(e.reqid===reqid){pollResult(cb,0,0,true,reqid,setmap,auth);return}
$("#save-btn").disabled=false;
if(cb)cb(null,false);else toast("Another change is being applied - retry shortly");
return;
}
// A network failure can lose the response after the POST landed. Poll the
// result by request ID so another or stale save cannot be mistaken for it.
pollResult(cb,0,0,false,reqid,setmap);
pollResult(cb,0,0,false,reqid,setmap,auth);
});
}
function appSave(){
@@ -1281,17 +1332,20 @@ function appSave(){
// acked: the node returned 202 for the POST, so the batch will be processed.
// A requested reboot happens only if every command succeeds. This still lets
// callers distinguish "confirmation lost" from "save never sent".
function pollResult(cb,errs,idles,acked,reqid,submitted){
function pollResult(cb,errs,idles,acked,reqid,submitted,auth){
errs=errs||0;idles=idles||0;
auth=auth||{password:submitted&&submitted.password||"",attempted:false};
function fail(){$("#save-btn").disabled=false;
if(cb)cb(null,acked);else toast(acked?"Saved, but confirmation was lost - reload to verify":"Save failed - check connection and retry")}
auth.password="";
if(auth.receiptSeen){toast("The save result was received. Sign in or reconnect to read the detailed replies.");return}
if(cb)cb(null,acked);else toast(acked?"Settings sent, but confirmation was lost - reload to verify":"Save failed - check connection and retry")}
api("/api/config/result?reqid="+encodeURIComponent(reqid),{timeout:4000}).then(function(r){
if(r.reqid!==reqid){fail();return}
if(r.state==="pending"){setTimeout(function(){pollResult(cb,0,idles,true,reqid,submitted)},400);return}
if(r.state==="pending"){setTimeout(function(){pollResult(cb,0,idles,true,reqid,submitted,auth)},400);return}
if(r.state!=="done"){
// idle: the POST likely never arrived - but give it a moment in case
// it's still in flight after a connection blip
if(idles<4){setTimeout(function(){pollResult(cb,errs,idles+1,acked,reqid,submitted)},700);return}
if(idles<4){setTimeout(function(){pollResult(cb,errs,idles+1,acked,reqid,submitted,auth)},700);return}
fail();return;
}
$("#save-btn").disabled=false;
@@ -1307,8 +1361,20 @@ function pollResult(cb,errs,idles,acked,reqid,submitted){
if(el)chipFor(el,ok,ok?"OK":it.reply.replace(/^Err(or)?[:,]?\s*/i,""));
});
$("#radio-warn").classList.toggle("hide",!radioReboot);
if(cb){cb(r);return}
if(fails)toast(fails+" setting(s) rejected - see fields");
var failed=fails>0||r.all_ok===false;
function reauthAfterReceipt(){
if(!r.reauth_required){auth.password="";return false}
auth.receiptSeen=true;
forgetSubmittedPassword(submitted);
if(auth.restored){if(!r.reboot||failed)loadConfigSoft();return true}
var note=failed?"The admin password changed, but some settings were rejected. The node will not reboot."
:r.reboot?"Settings saved. The node is rebooting.":"Settings saved. The admin password changed.";
if(st.mode==="setup"&&!r.reboot)note+=" The setup WiFi may restart. Rejoin it with the new admin password if prompted.";
reauthenticateOnce(auth,note,function(){pollResult(cb,0,0,true,reqid,submitted,auth)},!!r.reboot&&!failed);
return true;
}
if(cb){cb(r);reauthAfterReceipt();return}
if(failed)toast(fails?fails+" setting(s) rejected - see fields":"Some settings were rejected - see fields");
else if(r.reboot){
st.dirty={};
var bluetoothAddressChanged=submitted&&("bluetooth.mac" in submitted);
@@ -1321,16 +1387,20 @@ function pollResult(cb,errs,idles,acked,reqid,submitted){
? "The node is restarting with the saved stealth flag. Its address policy is unchanged. When enabling stealth, pair once; afterward reconnect using the saved device."
: "The node is restarting with the saved WiFi settings. Reconnect to that network and open the node at its router-assigned address.",
false,bluetoothAddressChanged?"Bluetooth address saved [OK] - rebooting":bluetoothStealthChanged?"Bluetooth stealth saved [OK] - rebooting":"Settings saved [OK] - rebooting",r.wifi_ip,rebootSeconds(r));
reauthAfterReceipt();
return;
}else toast("Saved [OK]");
loadConfigSoft();
if(!reauthAfterReceipt())loadConfigSoft();
}).catch(function(e){
if(e.message==="auth"){fail();return}
if(e.message==="auth"){
reauthenticateOnce(auth,auth.receiptSeen?"The save result was received. Sign in to read its details.":"Settings were sent. Sign in to read the saved result.",function(){pollResult(cb,errs,idles,acked,reqid,submitted,auth)},false);
return;
}
if(e.status===400||e.status===404){fail();return}
// Transient network error: the save itself can knock the phone off the
// AP for a moment (flash writes stall WiFi). Keep polling - the device
// holds the result until we manage to read it.
if(errs<20){setTimeout(function(){pollResult(cb,errs+1,idles,acked,reqid,submitted)},700);return}
if(errs<20){setTimeout(function(){pollResult(cb,errs+1,idles,acked,reqid,submitted,auth)},700);return}
fail();
});
}
@@ -1373,10 +1443,8 @@ function enterApp(){
});
}
// Setup-mode shortcut: straight past the guided steps into the terminal, for
// operators who already have a config to paste. Setup mode authenticates by
// proximity to the AP, so this hands the whole command surface to anyone in
// range -- the same trust the wizard already extends, since it can set the admin
// password and reflash the node's identity too.
// operators who already have a config to paste. The server's setup WiFi and
// admin-login policy also applies here; showing a tab grants no extra access.
function enterConsole(){
enterApp();
$('#tabs button[data-t="cli"]').click();
@@ -1720,6 +1788,11 @@ function adminPwdError(finishing){
var p=eff("password"),c=$('[data-cfm="password"]').value;
if(finishing&&st.needsPassword&&!p)return"Set an admin password";
if((p||c)&&p!==c)return"Admin passwords do not match";
if(p){
var bytes=0;
try{bytes=encodeURIComponent(p).replace(/%[0-9A-F]{2}/g,"x").length}catch(e){return"Admin password must be valid UTF-8"}
if(bytes>15||/[\r\n]/.test(p))return"Admin password must be 1-15 UTF-8 bytes with no line breaks";
}
return"";
}
function buildReview(){
@@ -1778,8 +1851,8 @@ function wizardSave(){
return;
}
var fails=(r.results||[]).filter(function(x){return!/^OK/i.test(x.reply)});
if(fails.length){
$("#wz-err").textContent=fails.map(function(x){return x.key+": "+x.reply}).join(" * ");
if(fails.length||r.all_ok===false){
$("#wz-err").textContent=fails.length?fails.map(function(x){return x.key+": "+x.reply}).join(" * "):"Some settings were rejected. Review the fields before trying again.";
return;
}
if(r.wifi_ip){
@@ -2529,9 +2602,10 @@ function cliRun(cmds){
cliBusy(true);
cliGap();
var reqid=mkReqId();
var auth=cliPasswordContext(cmds);
var status=cliEcho("sys",cmds.length>1?"running 0/"+cmds.length+"...":"...");
post("/api/cli",{reqid:reqid,cmds:cmds}).then(function(){
cliPoll(reqid,cmds,0,status,0,0);
cliPoll(reqid,cmds,0,status,0,0,auth);
}).catch(function(e){
if(e.message==="auth"){cliBusy(false);status.remove();return}
// No such endpoint: this firmware predates the console (or was built
@@ -2541,9 +2615,14 @@ function cliRun(cmds){
if(e.status===400||e.status===413){cliEnd(status,e.message||"Rejected by the node.");return}
// Ambiguous: the request may have landed even though the reply was lost.
// Poll for it rather than reporting a failure that did not happen.
cliPoll(reqid,cmds,0,status,0,0);
cliPoll(reqid,cmds,0,status,0,0,auth);
});
}
function cliPasswordContext(cmds){
var password="";
cmds.forEach(function(c){if(/^password /i.test(c))password=c.slice(9)});
return{password:password,attempted:false,required:false,view:"#v-app",output:[]};
}
// Stream replies for every role. Companion sessions also own recipient/login
// state and keep reading after completion to show ACKs and RF replies.
@@ -2585,6 +2664,7 @@ function cliStreamSend(){
if(cliStream.session===session)cliStreamPoll();
}).catch(function(e){
if(cliStream.session!==session)return;
if(e.status===401){cliStreamAuthorizationLost(false);return}
if(e.status>=400&&e.status<500||e.status===503){
cliEcho("err",e.message||"Command rejected.");
if(e.status===400){cliStream.seq--;cliStream.job=null;cliBusy(false)}
@@ -2595,6 +2675,13 @@ function cliStreamSend(){
cliStreamPoll();
});
}
function cliStreamAuthorizationLost(mayHaveRun){
var job=cliStream.job;
var auth=cliPasswordContext(mayHaveRun&&job?[job.cmds[job.index]]:[]);
var note="Terminal authorization changed. Sign in to continue; the command will not be resent.";
cliEcho("err",note);cliStreamReset();
reauthenticateOnce(auth,note,loadConfigSoft,false);
}
function cliStreamPoll(){
clearTimeout(cliStream.timer);
if(!cliStream.session||cliStream.polling)return;
@@ -2610,7 +2697,11 @@ function cliStreamPoll(){
if(r.output&&cliStream.job)cliStream.job.started=Date.now();
if(r.more){cliStream.timer=setTimeout(cliStreamPoll,0);return}
var job=cliStream.job;
if(r.closed){cliStreamReset();return}
if(r.closed){
if(job&&/^password /i.test(job.cmds[job.index]))cliStreamAuthorizationLost(true);
else cliStreamReset();
return;
}
if(job&&r.seq===job.seq&&r.done){
cliAfter([job.cmds[job.index]],{});
cliStream.out=null;
@@ -2624,6 +2715,7 @@ function cliStreamPoll(){
}).catch(function(e){
cliStream.polling=false;
if(cliStream.session!==session){cliStreamPoll();return}
if(e.status===401){if(e.staleAuth)cliStreamReset();else cliStreamAuthorizationLost(true);return}
if(e.status===401||e.status===403||e.status===404||++cliStream.errors>20){
cliEcho("err",e.message||"Terminal disconnected.");cliStreamReset();return;
}
@@ -2640,66 +2732,91 @@ function cliEnd(status,msg){
status.className="err";status.textContent=msg;
$("#term-out").scrollTop=$("#term-out").scrollHeight;
}
function cliPoll(reqid,cmds,from,status,errs,idles){
function cliPoll(reqid,cmds,from,status,errs,idles,auth){
auth=auth||cliPasswordContext(cmds);
api("/api/cli/result?reqid="+encodeURIComponent(reqid)+"&from="+from,{timeout:5000})
.then(function(r){
if(r.state!=="idle"&&r.reqid!==reqid){cliEnd(status,"Lost track of this sequence -- reload to check the node's state.");return}
if(r.state==="idle"){
// the POST may still be in flight after a connection blip
if(idles<5){setTimeout(function(){cliPoll(reqid,cmds,from,status,errs,idles+1)},400);return}
if(idles<5){setTimeout(function(){cliPoll(reqid,cmds,from,status,errs,idles+1,auth)},400);return}
cliEnd(status,"The node never received the command.");return;
}
auth.required=auth.required||!!r.reauth_required;
if(r.reauth_required)auth.receiptSeen=true;
if(auth.replaceReceipt&&!r.reauth_required){
auth.output.forEach(function(el){el.remove()});auth.output=[];auth.replaceReceipt=false;
}
(r.results||[]).forEach(function(x,i){
// The node never echoes the command back -- it may hold a password or a
// token, and we already have the sequence we sent. Match by index.
cliEcho("cmd",cmds[from+i]||"");
auth.output.push(cliEcho("cmd",cmds[from+i]||""));
// `ok` is advisory; the node's own convention is authoritative, and only
// failure has a fixed shape there ("Err"/"ERR:"/"Error:").
var ok=(x.ok!=null)?x.ok:!/^\s*err/i.test(x.reply||"");
if(!auth.attempted&&ok&&/^password /i.test(cmds[from+i]||""))auth.password=cmds[from+i].slice(9);
// Getters answer "> value" -- that leading marker is the serial console's
// way of setting a value apart, and here it collides with the prompt glyph
// that means "you typed this". Drop it; the colour already says "reply".
var reply=(x.reply||"").replace(/^>\s?/,"");
if(reply)cliEcho(ok?"rep":"err",reply);
if(reply)auth.output.push(cliEcho(ok?"rep":"err",reply));
});
from+=(r.results||[]).length;
// "running" also covers "finished, but more results are still to be paged
// over", so keep polling until the node says done.
if(r.state!=="done"){
if(cmds.length>1)status.textContent="running "+from+"/"+cmds.length+"...";
setTimeout(function(){cliPoll(reqid,cmds,from,status,0,0)},250);
setTimeout(function(){cliPoll(reqid,cmds,from,status,0,0,auth)},250);
return;
}
status.remove();
cliBusy(false);
cliAfter(cmds,r);
if(auth.required)r.reauth_required=true;
cliAfter(cmds,r,auth);
}).catch(function(e){
if(e.message==="auth"){cliBusy(false);status.remove();return}
if(e.status===400||e.status===404){cliEnd(status,"The node no longer has a result for this sequence.");return}
if(errs<20){setTimeout(function(){cliPoll(reqid,cmds,from,status,errs+1,idles)},700);return}
cliEnd(status,"Lost the connection while the sequence was running -- reload to check the node's state.");
if(e.message==="auth"){
reauthenticateOnce(auth,"Commands were sent. Sign in to read their results; they will not be resent.",function(){cliPoll(reqid,cmds,from,status,errs,idles,auth)},false);
return;
}
if(e.status===400||e.status===404){cliEnd(status,auth.receiptSeen?"The command result was received, but its detailed replies are no longer available.":"The node no longer has a result for this sequence.");return}
if(errs<20){setTimeout(function(){cliPoll(reqid,cmds,from,status,errs+1,idles,auth)},700);return}
cliEnd(status,auth.receiptSeen?"The command result was received. Reconnect to read its detailed replies.":"Lost the connection while the sequence was running -- reload to check the node's state.");
});
}
// A CLI `set` writes the same prefs the forms edit, so re-read them or the
// other tabs keep showing stale values.
function cliAfter(cmds,r){
function cliAfter(cmds,r,auth){
auth=auth||cliPasswordContext(cmds);
var touched=false;
cmds.forEach(function(c){
if(/^password\s/.test(c))cli.pwd=true;
if(/^(set|password)\s/.test(c))touched=true;
});
// Same prefix dispatch as the risk list: `poweroff now` powers off too.
if(touched)loadConfigSoft();
var reauth=r&&r.reauth_required&&!(auth&&auth.restored);
var failed=r&&(r.reboot_withheld||r.all_ok===false);
function finishAuth(){
if(!reauth){if(auth)auth.password="";return}
reauthenticateOnce(auth||cliPasswordContext(cmds),failed?"The admin password changed, but a command was rejected. The node will not reboot.":"The command results are complete. Sign in with the new admin password.",
function(){
auth.required=false;auth.replaceReceipt=true;cliBusy(true);
var status=cliEcho("sys","Reading authenticated command results...");
cliPoll(r.reqid,cmds,0,status,0,0,auth);
},!!r.reboot&&!failed);
}
if(touched&&!reauth)loadConfigSoft();
// A `reboot` in the sequence is not run by the CLI -- Board::reboot() never
// returns, so the node answers it and schedules the restart for after this
// read. It withholds it when any command failed, exactly as a config save
// does; say which happened rather than leaving the operator to guess.
if(r&&r.reboot_withheld){
if(failed){
cliEcho("err","Not rebooting -- a setting was rejected. Fix it and run \"reboot\" again.");
finishAuth();
return;
}
if(r&&r.reboot){
showReboot("The node is restarting. This page will try to reconnect automatically.",true);
finishAuth();
return;
}
// clkreboot / poweroff / erase-and-flash take the node down themselves, so
@@ -2708,6 +2825,7 @@ function cliAfter(cmds,r){
if(/^(poweroff|shutdown)/.test(c))showReboot("The node is powering off. Reconnect power to bring it back.",false,"Powering off...");
else if(/^clkreboot/.test(c))showReboot("The node is restarting. This page will try to reconnect automatically.",true);
});
finishAuth();
}
/* ---------- CLI: fit ----------