Skip to content

Commit

Permalink
add /check route
Browse files Browse the repository at this point in the history
  • Loading branch information
C4illin committed Mar 4, 2024
1 parent e0e9762 commit 86d82fc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,28 @@ app.get("/ping", async (_, res) => {
}
});

app.post("/check", async (req, res) => {
let uuid = req.body.uuid;

let conn;
try {
conn = await pool.getConnection();
let sql = "SELECT * FROM users WHERE uuid = ?";
let rows = await conn.query(sql, [uuid]);
if (rows.length > 0) {
res.send({ status: rows[0].active ? "success" : "denied" });
} else {
res.send({ status: "denied" });
}
} catch (err) {
console.error(err);
res.send({ status: "denied" });
} finally {
if (conn) conn.end();
}
});


app.listen(port, () => {
console.log(`App listening at http://localhost:${port}`);
});

0 comments on commit 86d82fc

Please sign in to comment.