1
0
Fork 0

Merge branch 'back' into 'master'

Fix of sessionCheck and register misspell var

See merge request LETU/LETU!12
This commit is contained in:
Ethanell 2020-11-03 09:12:26 +01:00
commit cf5f172b59
2 changed files with 3 additions and 3 deletions

View file

@ -4,10 +4,10 @@ function sessionCheck(permission) {
return (req, res, next) => { return (req, res, next) => {
if (permission === -1 && req.session.user) { if (permission === -1 && req.session.user) {
res.redirect(req.session.lastUrl); res.redirect(req.session.lastUrl);
} if (!req.session.user) { } else if (permission !== -1 && !req.session.user) {
req.session.lastUrl = req.originalUrl; req.session.lastUrl = req.originalUrl;
req.session.save(() => res.redirect("/login")); 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); return error(req, res, "Permission denied !", 403);
} else } else
next(); next();

View file

@ -8,7 +8,7 @@ module.exports = socket => {
else if ((!data.email.endsWith("@univ-lyon1.fr")) && (!data.email.endsWith("@etu.univ-lyon1.fr"))) else if ((!data.email.endsWith("@univ-lyon1.fr")) && (!data.email.endsWith("@etu.univ-lyon1.fr")))
socket.emit("register", {error: {message: "invalid_email"}}); socket.emit("register", {error: {message: "invalid_email"}});
else { else {
let user = await modules.User.create({ let user = await models.User.create({
email: data.email, email: data.email,
firstName: data.firstName, firstName: data.firstName,
lastName: data.lastName, lastName: data.lastName,