26 lines
786 B
JavaScript
26 lines
786 B
JavaScript
//Call for listing all groups with their permissions - needed for control panel
|
|
//Groups without permissions also included
|
|
//
|
|
const handleListPerm = (req, res, db) => {
|
|
|
|
db.transaction ( trx => {
|
|
trx.select('groups.groupname', 'permissions.objname', 'permissions.type')
|
|
.from('groups')
|
|
.leftJoin('permissions', function () {
|
|
this.on('groups.groupname', 'ilike','permissions.owner')
|
|
})
|
|
.where('username', 'like', '')
|
|
.orderBy('groupname', 'asc')
|
|
.orderBy('objname', 'asc')
|
|
.then ( data => {
|
|
res.json(data);
|
|
})
|
|
.then(trx.commit)
|
|
.catch(trx.rollback)
|
|
.catch (err => res.status(400).json('Error accesing database.'))
|
|
})
|
|
}
|
|
|
|
module.exports = {
|
|
handleListPerm
|
|
} |