Upgrade permission check function
fixes videos appearing in Videos Table but cannot be played.video-slicer-reencoder
parent
01d1051e64
commit
48d7d6a99b
|
@ -150,7 +150,7 @@ module.exports = function(s,config){
|
||||||
}
|
}
|
||||||
if(config.debugLog === true){
|
if(config.debugLog === true){
|
||||||
// CANNOT USE `dbQuery.toString()` because it breaks the query
|
// CANNOT USE `dbQuery.toString()` because it breaks the query
|
||||||
console.log(options)
|
console.log(JSON.stringify(options,null,3))
|
||||||
}
|
}
|
||||||
if(callback || options.update || options.insert || options.action === 'delete'){
|
if(callback || options.update || options.insert || options.action === 'delete'){
|
||||||
dbQuery.asCallback(function(err,r) {
|
dbQuery.asCallback(function(err,r) {
|
||||||
|
@ -331,10 +331,7 @@ module.exports = function(s,config){
|
||||||
var endTimeOperator = options.endTimeOperator
|
var endTimeOperator = options.endTimeOperator
|
||||||
var startTime = options.startTime
|
var startTime = options.startTime
|
||||||
var limitString = `${options.limit}`
|
var limitString = `${options.limit}`
|
||||||
const {
|
const monitorRestrictions = options.monitorRestrictions || s.getMonitorsPermitted(user.details,monitorId).monitorRestrictions
|
||||||
monitorPermissions,
|
|
||||||
monitorRestrictions,
|
|
||||||
} = s.getMonitorsPermitted(user.details,monitorId)
|
|
||||||
getDatabaseRows({
|
getDatabaseRows({
|
||||||
monitorRestrictions: monitorRestrictions,
|
monitorRestrictions: monitorRestrictions,
|
||||||
table: theTableSelected,
|
table: theTableSelected,
|
||||||
|
|
|
@ -1866,9 +1866,12 @@ module.exports = function(s,config,lang){
|
||||||
});
|
});
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
s.getMonitorsPermitted = (userDetails,monitorId) => {
|
s.getMonitorsPermitted = (userDetails,monitorId,permissionTarget) => {
|
||||||
const monitorRestrictions = []
|
const monitorRestrictions = []
|
||||||
const monitors = {}
|
const monitors = {}
|
||||||
|
permissionTarget = permissionTarget || 'monitors'
|
||||||
|
const permissionSet = s.parseJSON(userDetails[permissionTarget]) || []
|
||||||
|
// const viewOnlyCheck = permissionTarget === 'monitors'
|
||||||
function setMonitorPermissions(mid){
|
function setMonitorPermissions(mid){
|
||||||
// monitors : Can View Monitor
|
// monitors : Can View Monitor
|
||||||
// monitor_edit : Can Edit Monitor (Delete as well)
|
// monitor_edit : Can Edit Monitor (Delete as well)
|
||||||
|
@ -1894,12 +1897,11 @@ module.exports = function(s,config,lang){
|
||||||
if(
|
if(
|
||||||
!monitorId &&
|
!monitorId &&
|
||||||
userDetails.sub &&
|
userDetails.sub &&
|
||||||
userDetails.monitors &&
|
permissionSet &&
|
||||||
userDetails.allmonitors !== '1'
|
userDetails.allmonitors !== '1'
|
||||||
){
|
){
|
||||||
try{
|
try{
|
||||||
userDetails.monitors = s.parseJSON(userDetails.monitors)
|
permissionSet.forEach(function(v,n){
|
||||||
userDetails.monitors.forEach(function(v,n){
|
|
||||||
setMonitorPermissions(v)
|
setMonitorPermissions(v)
|
||||||
addToQuery(v,n)
|
addToQuery(v,n)
|
||||||
})
|
})
|
||||||
|
@ -1910,7 +1912,7 @@ module.exports = function(s,config,lang){
|
||||||
monitorId && (
|
monitorId && (
|
||||||
!userDetails.sub ||
|
!userDetails.sub ||
|
||||||
userDetails.allmonitors !== '0' ||
|
userDetails.allmonitors !== '0' ||
|
||||||
userDetails.monitors.indexOf(monitorId) >- 1
|
permissionSet.indexOf(monitorId) >- 1
|
||||||
)
|
)
|
||||||
){
|
){
|
||||||
setMonitorPermissions(monitorId)
|
setMonitorPermissions(monitorId)
|
||||||
|
|
|
@ -974,7 +974,7 @@ module.exports = function(s,config,lang,app,io){
|
||||||
const {
|
const {
|
||||||
monitorPermissions,
|
monitorPermissions,
|
||||||
monitorRestrictions,
|
monitorRestrictions,
|
||||||
} = s.getMonitorsPermitted(user.details,monitorId)
|
} = s.getMonitorsPermitted(user.details,monitorId,'video_view')
|
||||||
const {
|
const {
|
||||||
isRestricted,
|
isRestricted,
|
||||||
isRestrictedApiKey,
|
isRestrictedApiKey,
|
||||||
|
@ -1014,6 +1014,7 @@ module.exports = function(s,config,lang,app,io){
|
||||||
endIsStartTo: !!req.query.endIsStartTo,
|
endIsStartTo: !!req.query.endIsStartTo,
|
||||||
parseRowDetails: false,
|
parseRowDetails: false,
|
||||||
rowName: 'videos',
|
rowName: 'videos',
|
||||||
|
monitorRestrictions: monitorRestrictions,
|
||||||
preliminaryValidationFailed: false
|
preliminaryValidationFailed: false
|
||||||
},(response) => {
|
},(response) => {
|
||||||
if(response && response.videos){
|
if(response && response.videos){
|
||||||
|
|
Loading…
Reference in New Issue