diff --git a/index.js b/index.js index 57242e8..d2fbdc3 100644 --- a/index.js +++ b/index.js @@ -26,11 +26,11 @@ app.get('/', (req, res) => { }) app.get('/scoreboard', (req, res) => { - return res.sendFile(path.normalize(path.join(__dirname, 'public/pages/scoreboardView.html'))) + return res.sendFile(path.normalize(path.join(__dirname, '/public/pages/scoreboardView.html'))) }) app.get('/register', (req, res) => { - return res.sendFile(path.normalize(path.join(__dirname, '/public/pages/signupView.html'))) + return res.sendFile(path.normalize(path.join(__dirname, '/public/pages/signupView.html'))) }) app.get('/game', (req, res) => { @@ -130,7 +130,7 @@ app.get('/user-info', (req, res) => { } try { - const decoded = jwt.verify(token, secretKey); + const decoded = jwt.verify(token, secretKey); const query = 'SELECT pseudo FROM users WHERE pseudo = ?'; db.query(query, [decoded.pseudo], (err, results) => { if (err) { @@ -143,6 +143,7 @@ app.get('/user-info', (req, res) => { return res.json(results[0]); }); } catch (ex) { + console.log(ex) return res.status(400).send('Invalid token.'); } }); diff --git a/public/pages/gameView.html b/public/pages/gameView.html index e3de987..67684ae 100644 --- a/public/pages/gameView.html +++ b/public/pages/gameView.html @@ -85,7 +85,7 @@
- + see scorebaord diff --git a/public/scripts/app.js b/public/scripts/app.js index be8dd6f..fb0dc87 100644 --- a/public/scripts/app.js +++ b/public/scripts/app.js @@ -73,19 +73,10 @@ socket.on('opponent left', () => { modal.style.display = 'block'; }) -function deleteCookie(name) { - document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; -} - socket.on("go to menu", () => { goToMenu() }) -socket.on("disconnect", () => { - deleteCookie('authToken'); - window.location.href = "/" -}); - // #region rematch handling socket.on("ask for rematch", () => { diff --git a/public/scripts/gamePageInfo.js b/public/scripts/gamePageInfo.js index b684368..6c202b7 100644 --- a/public/scripts/gamePageInfo.js +++ b/public/scripts/gamePageInfo.js @@ -1,7 +1,3 @@ -function deleteCookie(name) { - document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; -} - document.addEventListener('DOMContentLoaded', async () => { const playerInfoDiv = document.getElementById('playerInfo'); @@ -14,10 +10,8 @@ document.addEventListener('DOMContentLoaded', async () => { }); if (response.status === 401) { - deleteCookie('authToken'); window.location.href = '/'; } else if (!response.ok) { - deleteCookie('authToken'); playerInfoDiv.textContent = 'Error: Could not retrieve user information.'; window.location.href = '/'; } else {