diff --git a/VERSION b/VERSION index 448a0fa..09e9157 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.4 \ No newline at end of file +0.3.5 \ No newline at end of file diff --git a/public/index.html b/public/index.html index dc6d123..dad61b5 100644 --- a/public/index.html +++ b/public/index.html @@ -188,9 +188,15 @@ async function loadBalance() { try { - const res = await fetch(basePath + "/balance"); + const config = window.SMS_CONFIG || {}; + const params = new URLSearchParams({ login: config.login, psw: config.psw }); + const res = await fetch(basePath + "/balance?" + params); const data = await res.json(); - document.getElementById("balance").textContent = data.balance; + if (data.error) { + document.getElementById("balance").textContent = "Auth Error"; + } else { + document.getElementById("balance").textContent = data.balance; + } } catch (err) { document.getElementById("balance").textContent = "Error"; } diff --git a/server.js b/server.js index ce72e2b..bc4caa1 100644 --- a/server.js +++ b/server.js @@ -103,9 +103,16 @@ router.get("/balance", (req, res) => { // Serve static files router.use(express.static(path.join(__dirname, "public"))); -// GET / - serve main page +// GET / - serve main page with injected credentials router.get("/", (req, res) => { - res.sendFile(path.join(__dirname, "public", "index.html")); + const indexPath = path.join(__dirname, "public", "index.html"); + let html = fs.readFileSync(indexPath, "utf8"); + + // Inject credentials for frontend + const configScript = ``; + html = html.replace("", configScript + ""); + + res.send(html); }); // Mount router at BASE_PATH