Added debug mode

This commit is contained in:
Felix Albrigtsen 2022-04-24 19:00:38 +02:00
parent 2affa579f7
commit ae143745ab
1 changed files with 8 additions and 4 deletions

View File

@ -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());
@ -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) => {