From fe8c420105793baa2b50127270ff0627889675f1 Mon Sep 17 00:00:00 2001 From: flifloo Date: Tue, 3 Nov 2020 09:11:58 +0100 Subject: [PATCH] Fix of sessionCheck and register misspell var --- routes/utils/sessionCheck.js | 4 ++-- sockets/register.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routes/utils/sessionCheck.js b/routes/utils/sessionCheck.js index 7d5d7c9..786bc56 100644 --- a/routes/utils/sessionCheck.js +++ b/routes/utils/sessionCheck.js @@ -4,10 +4,10 @@ function sessionCheck(permission) { return (req, res, next) => { if (permission === -1 && req.session.user) { res.redirect(req.session.lastUrl); - } if (!req.session.user) { + } else if (permission !== -1 && !req.session.user) { req.session.lastUrl = req.originalUrl; req.session.save(() => res.redirect("/login")); - } else if (req.session.user.permissions < permission) { + } else if (req.session.user && req.session.user.permissions < permission) { return error(req, res, "Permission denied !", 403); } else next(); diff --git a/sockets/register.js b/sockets/register.js index bcbf398..9e8d4e7 100644 --- a/sockets/register.js +++ b/sockets/register.js @@ -8,7 +8,7 @@ module.exports = socket => { else if ((!data.email.endsWith("@univ-lyon1.fr")) && (!data.email.endsWith("@etu.univ-lyon1.fr"))) socket.emit("register", {error: {message: "invalid_email"}}); else { - let user = await modules.User.create({ + let user = await models.User.create({ email: data.email, firstName: data.firstName, lastName: data.lastName,