Added frond-end and needed get calls.
This commit is contained in:
29
endpoints/listuserpermissions.js
Normal file
29
endpoints/listuserpermissions.js
Normal file
@@ -0,0 +1,29 @@
|
||||
//Call for listing all users with their permissions - needed for control panel
|
||||
//Users without permissions also included
|
||||
//
|
||||
const handleListPerm = (req, res, db) => {
|
||||
|
||||
db.transaction ( trx => {
|
||||
trx.select('users.username', 'permissions.objname', 'permissions.type')
|
||||
.from('groups')
|
||||
.fullOuterJoin('permissions', function () {
|
||||
this.on('groups.groupname', '=', 'permissions.owner')
|
||||
})
|
||||
.rightJoin('users', function () {
|
||||
this.on('groups.username', 'ilike','users.username')
|
||||
.orOn('permissions.owner', 'ilike', 'users.username')
|
||||
})
|
||||
.orderBy('username', '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
|
||||
}
|
||||
Reference in New Issue
Block a user