This commit is contained in:
2023-12-08 02:12:49 +01:00
parent 5a7656046c
commit 9b671a5e2b
2 changed files with 17 additions and 3 deletions

View File

@@ -57,4 +57,11 @@ CREATE TABLE game_questions (
PRIMARY KEY (id),
INDEX gq_game_idx (game),
INDEX gq_question_idx (question)
) ENGINE=InnoDB;
) 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');

View File

@@ -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);