diff --git a/app/services/MembresServ.js b/app/services/MembresServ.js index 8f453fd..5a53681 100644 --- a/app/services/MembresServ.js +++ b/app/services/MembresServ.js @@ -43,4 +43,18 @@ MembresServ.remove = function (id, cb) { }, cb); }; +MembresServ.estBureau = function (login, cb) { + MembreModl.findOne({ + login: login + }, function (err, data) { + if (!err && data && data.role != 'Membre') { + cb(true); + console.log(true); + } else { + cb(false); + console.log(false); + } + }); +}; + module.exports = MembresServ; diff --git a/app/services/SessionsServ.js b/app/services/SessionsServ.js index 3ec6a82..937c2f5 100644 --- a/app/services/SessionsServ.js +++ b/app/services/SessionsServ.js @@ -1,5 +1,6 @@ var SessionModl = require('../models/SessionModl'); var NomsServ = require('../services/NomsServ'); +var MembresServ = require('../services/MembresServ'); var SshAuthServ = require('../services/SshAuthServ'); var sessions = {}; @@ -11,14 +12,17 @@ sessions.addData = function (session, cb) { // Nom session.nom = nom.nom; session.section = nom.section; - // Permissions - session.canAddMembre = session.login == 'gbontoux'; - session.canDelMembre = session.login == 'gbontoux'; - session.canAddConv = true; - session.canDelConv = session.login == 'gbontoux'; - session.canAddMess = true; - session.canDelMess = session.login == 'gbontoux'; - cb(session); + MembresServ.estBureau(session.login, function (bureau) { + session.bureau = bureau; + // Permissions + session.canAddMembre = session.bureau; + session.canDelMembre = session.bureau; + session.canAddConv = true; + session.canDelConv = session.bureau; + session.canAddMess = true; + session.canDelMess = session.bureau; + cb(session); + }); }); }; -- libgit2 0.21.2