Commit 0f7812f56919990d86cac4e14154fe9ca4ce91dc
1 parent
e4fff96c
Reconaissance des membres du bureau
Je suis bureau !
Showing
2 changed files
with
26 additions
and
8 deletions
Show diff stats
app/services/MembresServ.js
... | ... | @@ -43,4 +43,18 @@ MembresServ.remove = function (id, cb) { |
43 | 43 | }, cb); |
44 | 44 | }; |
45 | 45 | |
46 | +MembresServ.estBureau = function (login, cb) { | |
47 | + MembreModl.findOne({ | |
48 | + login: login | |
49 | + }, function (err, data) { | |
50 | + if (!err && data && data.role != 'Membre') { | |
51 | + cb(true); | |
52 | + console.log(true); | |
53 | + } else { | |
54 | + cb(false); | |
55 | + console.log(false); | |
56 | + } | |
57 | + }); | |
58 | +}; | |
59 | + | |
46 | 60 | module.exports = MembresServ; | ... | ... |
app/services/SessionsServ.js
1 | 1 | var SessionModl = require('../models/SessionModl'); |
2 | 2 | var NomsServ = require('../services/NomsServ'); |
3 | +var MembresServ = require('../services/MembresServ'); | |
3 | 4 | var SshAuthServ = require('../services/SshAuthServ'); |
4 | 5 | |
5 | 6 | var sessions = {}; |
... | ... | @@ -11,14 +12,17 @@ sessions.addData = function (session, cb) { |
11 | 12 | // Nom |
12 | 13 | session.nom = nom.nom; |
13 | 14 | session.section = nom.section; |
14 | - // Permissions | |
15 | - session.canAddMembre = session.login == 'gbontoux'; | |
16 | - session.canDelMembre = session.login == 'gbontoux'; | |
17 | - session.canAddConv = true; | |
18 | - session.canDelConv = session.login == 'gbontoux'; | |
19 | - session.canAddMess = true; | |
20 | - session.canDelMess = session.login == 'gbontoux'; | |
21 | - cb(session); | |
15 | + MembresServ.estBureau(session.login, function (bureau) { | |
16 | + session.bureau = bureau; | |
17 | + // Permissions | |
18 | + session.canAddMembre = session.bureau; | |
19 | + session.canDelMembre = session.bureau; | |
20 | + session.canAddConv = true; | |
21 | + session.canDelConv = session.bureau; | |
22 | + session.canAddMess = true; | |
23 | + session.canDelMess = session.bureau; | |
24 | + cb(session); | |
25 | + }); | |
22 | 26 | }); |
23 | 27 | }; |
24 | 28 | ... | ... |