From bff4e8373011f1d107a5042956bd863352b1a884 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Mon, 25 Apr 2022 13:19:59 +0200 Subject: [PATCH] Fix logout redirect --- src/server/index.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/server/index.js b/src/server/index.js index 57579ed..ac16cd9 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -289,13 +289,18 @@ api.post("/match/:matchId/setWinner", async (req, res) => { res.json({"status": "error", "data": "matchId must be a number"}); return } - if (winnerId == undefined || isNaN(winnerId)) { + if (winnerId == undefined || (isNaN(winnerId) && winnerId != "null")) { res.json({"status": "error", "data": "winnerId must be a number"}); return } + matchId = parseInt(matchId); - winnerId = parseInt(winnerId); + if (winnerId == "null") { + winnerId = null; + } else { + winnerId = parseInt(winnerId); + } tmdb.setMatchWinner(matchId, winnerId) .then(match => res.send({"status": "OK", "data": match})) .catch(err => res.send({"status": "error", "data": err})); @@ -484,11 +489,6 @@ function isSessionManager(session) { }); } -api.get("/logout", (req, res) => { - req.session.destroy(); - res.redirect(process.env.AUTH_SUCCESS_REDIRECT); -}); - api.get("/users/getSavedUser", (req, res) => { if (!req.session.user) { res.json({"status": "error", "data": "No user logged in"}); @@ -565,6 +565,11 @@ api.delete("/users/:asuraId", async (req, res) => { .catch(err => res.json({"status": "error", "data": err})); }); +api.get("/users/logout", (req, res) => { + req.session.destroy(); + res.redirect(process.env.AUTH_SUCCESS_REDIRECT); +}); + // Debugging functions, disabled on purpouse // api.get("/users/getSessionUser", (req, res) => {