vicinityManager/server/services/items/update.js
/*
Check if user can update a device based on its roles
*/
Check if user can update a device based on its roles
Check if user can update a device based on its roles
function checkUserAuth(roles, tokenUser, typeOfItem, itemUser){
  var imAdmin = roles.indexOf('administrator') !== -1;
  var canChangeSer, canChangeDev;
  if(tokenUser === itemUser){
    canChangeDev = (roles.indexOf('infrastructure operator') !== -1 && typeOfItem === 'device');
    canChangeSer = (roles.indexOf('service provider') !== -1 && typeOfItem === 'service');
  } else {
    canChangeDev = canChangeSer = false;
  }
  return imAdmin || canChangeSer || canChangeDev;
}
function checkUserAuth ( roles , tokenUser , typeOfItem , itemUser ) { var imAdmin = roles . indexOf ( 'administrator' ) !== - 1 ; var canChangeSer , canChangeDev ; if ( tokenUser === itemUser ) { canChangeDev = ( roles . indexOf ( 'infrastructure operator' ) !== - 1 && typeOfItem === 'device' ) ; canChangeSer = ( roles . indexOf ( 'service provider' ) !== - 1 && typeOfItem === 'service' ) ; } else { canChangeDev = canChangeSer = false ; } return imAdmin || canChangeSer || canChangeDev ; }
Check if user can update a device based on its roles
Check if user can update a device based on its roles