From 16ebbb932c0b780c11d3e574bc24a515eb095f5f Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 10 Oct 2020 18:37:26 +0200 Subject: Fixed navbar if not logged in --- auth/index.js | 10 +++++++++- auth/public/index.html | 1 - overview/public/index.html | 7 +++++-- overview/public/script.js | 22 ++++++++++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 overview/public/script.js diff --git a/auth/index.js b/auth/index.js index 40062cc..e40ea43 100644 --- a/auth/index.js +++ b/auth/index.js @@ -89,6 +89,14 @@ app.get("/api/list", checkUser, async (req, res) => { res.json(users); }); -app.get("/api/status", (req, res) => res.json({ loggedIn: req.session.loggedIn })); +app.get("/api/status", (req, res) => { + if (req.session.loggedIn) { + db.query("SELECT is_admin FROM users WHERE id = ?", [req.session.uid]).then((ret) => { + res.json({ loggedIn: req.session.loggedIn, admin: ret[0].is_admin ? true : false }); + }); + } else { + res.json({ loggedIn: false, admin: false }); + } +}); module.exports = { auth: app, checkUser, checkAdmin }; diff --git a/auth/public/index.html b/auth/public/index.html index b56db07..8273238 100644 --- a/auth/public/index.html +++ b/auth/public/index.html @@ -16,7 +16,6 @@