From f08e249701f5376b39d52161febd513885b61566 Mon Sep 17 00:00:00 2001 From: flifloo Date: Mon, 14 Dec 2020 23:00:47 +0100 Subject: [PATCH] Fix name and group display on views --- sockets/login.js | 2 +- views/template/navbar.pug | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/sockets/login.js b/sockets/login.js index 6d0b89a..70b4707 100644 --- a/sockets/login.js +++ b/sockets/login.js @@ -2,7 +2,7 @@ const models = require("../models"); module.exports = socket => { return async (data) => { - let user = await models.User.findByPk(data.email); + let user = await models.User.findByPk(data.email, {include: {model: models.Group, include: models.Semester}}); if (!user) socket.emit("login", {error: {message: "not_found"}}); else if (!user.checkPassword(data.password)) diff --git a/views/template/navbar.pug b/views/template/navbar.pug index 2da3620..99b6c62 100644 --- a/views/template/navbar.pug +++ b/views/template/navbar.pug @@ -1,18 +1,21 @@ extends layout block navbar - if student === true + if session.user.permissions === 1 div(id="navprofile" class="student" onclick="profilRedirect()") - p Kezel Benoit - p G4S3 + p=session.user.firstName + " " + session.user.lastName + if session.user.Groups[session.user.Groups.length-1].number.startsWith("G") + p=session.user.Groups[session.user.Groups.length-1].number + session.user.Groups[session.user.Groups.length-1].Semester.name + else + p=session.user.Groups[session.user.Groups.length-1].Semester.name + " " + session.user.Groups[session.user.Groups.length-1].number a(id="logout") Logout - if teacher === true + if session.user.permissions === 2 div(id="navprofile" class="teacher" onclick="profilRedirect()") - p Kezel Benoit + p=session.user.firstName + " " + session.user.lastName a(id="logout") Logout - if admin === true + if session.user.permissions === 3 div(id="navprofile" class="admin" onclick="profilRedirect()") - p Kezel Benoit + p=session.user.firstName + " " + session.user.lastName a(id="logout") Logout div(id="navtop")