popup 9
This commit is contained in:
parent
d70114cf21
commit
a3d2e357fc
16
app.js
16
app.js
@ -71,11 +71,23 @@ app.use(
|
||||
app.set("view engine", "ejs");
|
||||
app.set("views", path.join(__dirname, "views"));
|
||||
|
||||
/* ========================
|
||||
Login Middleware
|
||||
======================== */
|
||||
|
||||
function requireLogin(req, res, next) {
|
||||
if (!req.session.user) {
|
||||
return res.status(401).json({ error: "Nicht eingeloggt" });
|
||||
}
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
/* ========================
|
||||
Route für Ajax für Gebäude
|
||||
======================== */
|
||||
|
||||
app.get("/api/building/:id", async (req, res) => {
|
||||
app.get("/api/building/:id", requireLogin, async (req, res) => {
|
||||
const buildingId = req.params.id;
|
||||
const userId = req.session.user.id;
|
||||
|
||||
@ -125,7 +137,7 @@ app.get("/api/building/:id", async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/api/buildings", async (req, res) => {
|
||||
app.get("/api/buildings", requireLogin, async (req, res) => {
|
||||
const userId = req.session.user.id;
|
||||
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user