summaryrefslogtreecommitdiffstats
path: root/server/api/permissions.js
blob: bf24462340489fd588f351bd3fe638040312d565 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* global __appdir */
var path = require('path');
var db = require(path.join(__appdir, 'lib', 'sequelize'));

module.exports = {
    // Return ID, Description and Name of a given RoleID
    getRoleById: function(req, res) {
        var roleid = req.params.roleid;
        db.role.findById(roleid).then(role_db => {
            var role = { };
            role.id = role_db.id;
            role.descr = role_db.descr;
            role.name = role_db.name;
            res.status(200).send(role);
        });
    },
    // Return all RoleIDs associated to a given UserID
    getRolesByUserid: function(req, res) {
        // var userid = req.query.userid;
        // the usersxroles (and rolesxpermissions) models first have to get created
        /* db.usersxroles.findAndCountAll({ where: { id: userid }, attributes: ['roleid'] }).then(roles_db => {
            var result = { };
            result.count = roles_db.count;
            result.roles = roles_db.rows;
            res.status(200).send(result);
        });*/
    }
}