From 9b671a5e2b2857c7924f70afa922b04cc70e7624 Mon Sep 17 00:00:00 2001 From: Lightemerald Date: Fri, 8 Dec 2023 02:12:49 +0100 Subject: [PATCH] Fix --- api/database.sql | 9 ++++++++- api/routes/users.js | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/api/database.sql b/api/database.sql index 68667a8..6f9eed5 100644 --- a/api/database.sql +++ b/api/database.sql @@ -57,4 +57,11 @@ CREATE TABLE game_questions ( PRIMARY KEY (id), INDEX gq_game_idx (game), INDEX gq_question_idx (question) -) ENGINE=InnoDB; \ No newline at end of file +) ENGINE=InnoDB; + + +INSERT INTO themes (theme) VALUES ('Environnement'); +INSERT INTO themes (theme) VALUES ('Energie Renouvelable'); +INSERT INTO themes (theme) VALUES ("Recyclage et consommation d'energie"); +INSERT INTO themes (theme) VALUES ('Pollution et energie fossile'); +INSERT INTO themes (theme) VALUES ('Politique'); diff --git a/api/routes/users.js b/api/routes/users.js index 42f28ab..fea0600 100644 --- a/api/routes/users.js +++ b/api/routes/users.js @@ -63,8 +63,15 @@ router.post('/login', requestLimiter, async (req, res) => { }); router.post('verifyToken', requestLimiter, async (req, res) => { - const token = req.headers.authorization; - if (!token) return await respondWithStatus(res, 401, 'No token provided'); + try { + const token = req.headers.authorization; + if (!token) return await respondWithStatus(res, 401, 'No token provided'); + } + catch (error) { + console.error(error); + return await respondWithStatus(res, 500, 'An error has occured'); + } + try { const decoded = jwt.verify(token, process.env.JWT_SECRET);