From a83a5fd39a4479592e978c109e56bb5f2f0b6a94 Mon Sep 17 00:00:00 2001 From: William Mantly Date: Sat, 25 Jul 2026 23:15:07 -0400 Subject: [PATCH] app.api.delete: accept the (url, data, callback) form formAJAX uses; defer the login-card reveal to DOM ready formAJAX always passes the serialized form as the second argument, so a DELETE-method form (the host/DNS delete buttons) landed its callback in the data slot and never ran. The login page's "reveal the card once we know you're logged out" branch touched an element further down the same page, which threw when isLoggedIn answered before the parser got there (it always did without a stored token). It now runs on DOM ready. Co-Authored-By: Claude Opus 5 --- nodejs/public/lib/js/app-base.js | 9 ++++++++- nodejs/views/login.ejs | 20 ++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/nodejs/public/lib/js/app-base.js b/nodejs/public/lib/js/app-base.js index 2b323a3..d5fff48 100644 --- a/nodejs/public/lib/js/app-base.js +++ b/nodejs/public/lib/js/app-base.js @@ -129,7 +129,14 @@ app.api = (function(app){ return body('PUT', url, data, callback); } - function remove(url, callback){ + // Called both as (url, callback) and — from formAJAX, which always passes + // the serialized form as the second argument — as (url, data, callback). + // No request body is sent either way. + function remove(url, data, callback){ + if(typeof data === 'function'){ + callback = data; + data = undefined; + } if(typeof callback !== 'function'){ return new Promise(function(resolve, reject){ $.ajax({ diff --git a/nodejs/views/login.ejs b/nodejs/views/login.ejs index 85b9c97..9bd894d 100755 --- a/nodejs/views/login.ejs +++ b/nodejs/views/login.ejs @@ -4,14 +4,18 @@ // If we arrived from the OIDC callback with a token in the URL fragment, // store it and forward on before doing anything else. if(!app.auth.consumeTokenFragment()){ - app.auth.isLoggedIn(function(error, isLoggedIn){ - if(isLoggedIn){ - app.auth.logInRedirect(); - }else{ - // Reveal the login card once we know the user is not logged in. - document.getElementById('login-card-row').style.display = ''; - } - }) + // The reveal below touches an element further down this page, so wait + // for the DOM — isLoggedIn can answer before the parser gets there. + $(document).ready(function(){ + app.auth.isLoggedIn(function(error, isLoggedIn){ + if(isLoggedIn){ + app.auth.logInRedirect(); + }else{ + // Reveal the login card once we know the user is not logged in. + document.getElementById('login-card-row').style.display = ''; + } + }); + }); }