From ae143745abcbed6762b86fe28cbefa038ea16f2b Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Sun, 24 Apr 2022 19:00:38 +0200 Subject: [PATCH] Added debug mode --- src/server/index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/server/index.js b/src/server/index.js index a1b4fab..57579ed 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -9,8 +9,8 @@ let tmdb = require("./tmdb.js"); // #region Express setup const app = express(); -const port = 3001; -app.listen(port, () => { +const port = process.env.SERVER_PORT || 3000; +app.listen(parseInt(port), () => { console.log(`Listening on port ${port}`) }) app.use(express.json()); @@ -176,7 +176,7 @@ api.post("/tournament/:tournamentId/edit", async (req, res) => { res.json({"status": "error", "data": "User is not logged in"}); return } - + let tournamentId = req.params.tournamentId; if (isNaN(tournamentId)) { res.json({"status": "error", "data": "tournamentId must be a number"}); @@ -456,6 +456,8 @@ api.post("/tournament/create", async (req, res) => { function isSessionLoggedIn(session) { return new Promise((resolve, reject) => { + if (process.env.DEBUG_ALLOW_ALL === "true") { resolve(true); return; } + if (session.user == undefined || session.user.googleId == undefined) { return resolve(false); } @@ -470,6 +472,8 @@ function isSessionLoggedIn(session) { function isSessionManager(session) { return new Promise((resolve, reject) => { + if (process.env.DEBUG_ALLOW_ALL === "true") { resolve(true); return; } + if (session.user == undefined || session.user.googleId == undefined) { return resolve(false); } @@ -482,7 +486,7 @@ function isSessionManager(session) { api.get("/logout", (req, res) => { req.session.destroy(); - res.redirect("/"); + res.redirect(process.env.AUTH_SUCCESS_REDIRECT); }); api.get("/users/getSavedUser", (req, res) => {