diff options
Diffstat (limited to 'auth/index.js')
-rw-r--r-- | auth/index.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/auth/index.js b/auth/index.js index 3109586..6514a8d 100644 --- a/auth/index.js +++ b/auth/index.js @@ -93,4 +93,16 @@ app.get("/api/status", (req, res) => { res.json({ loggedIn: req.session.loggedIn, admin: req.session.isAdmin }); }); +app.get("/api/self", checkUser, async (req, res) => { + try { + const user = await db.query( + "SELECT id, username, name, middlename, surname, class_id, type_id, is_admin FROM users WHERE id = ?", + [req.session.uid]); + res.json(user[0]); + } catch (e) { + console.error(e); + return res.send("error"); + } +}); + module.exports = { auth: app, checkUser, checkAdmin }; |