openhim-core
Version:
The OpenHIM core application that provides logging and routing of http requests
43 lines (38 loc) • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.inGroup = inGroup;
exports.getUserViewableChannels = getUserViewableChannels;
exports.getUserRerunableChannels = getUserRerunableChannels;
var _channels = require('../model/channels');
function inGroup(group, user) {
return user.groups.indexOf(group) >= 0;
}
/**
* A promise returning function that returns the list
* of viewable channels for a user.
*/
function getUserViewableChannels(user) {
// if admin allow all channel
if (inGroup('admin', user)) {
return _channels.ChannelModelAPI.find({}).exec();
} else {
// otherwise figure out what this user can view
return _channels.ChannelModelAPI.find({ txViewAcl: { $in: user.groups } }).exec();
}
}
/**
* A promise returning function that returns the list
* of rerunnable channels for a user.
*/
function getUserRerunableChannels(user) {
// if admin allow all channel
if (inGroup('admin', user)) {
return _channels.ChannelModelAPI.find({}).exec();
} else {
// otherwise figure out what this user can rerun
return _channels.ChannelModelAPI.find({ txRerunAcl: { $in: user.groups } }).exec();
}
}
//# sourceMappingURL=authorisation.js.map