问题描述
我正在尝试根据用户类型过滤用户看到的内容。我在数据库中有3种用户类型作为选项。目前,我有一个数组可以过滤除有效的“国家联络代表”之外的所有内容。尽管我还需要它来过滤此“国家”表中的子级。基于关联的用户国家。我不确定这是最好的选择,还是不确定是否可以编写MysqL脚本并在后端执行。我愿意接受所有建议问题或评论。
console.log(reportingJSONObject);
// Loop on directorates
for (var i = 0; i < reportingJSONObject.tree.length; i++) {
// if isNLR,and not national liason rep skip
//hr_directory has an associated nation connected by nation
var directorateObject = reportingJSONObject.tree[i];
// var userNation = response.data.nation
if (is_nlr=true) {
console.log("isNLR");
if (directorateObject.name != "National Liaison Representative")
{
console.log("skipping entry " + directorateObject.name);
continue;
}
// gets rid of directorate entirely
// if (directorate = directorateObject.name) {
// continue;
// }
//
// if (currentVue.nation = userNation) {
// continue;
// }
};
解决方法
通常情况下,双方都对用户身份和权限有所了解。 JS代码可能会根据身份和权限显示不同的数据(“使用其他模板”等)。同时,主机是权威:它限制了可能使用的API调用,并确定它们各自返回的内容。它还提供了JS代码用来确定当前用户权限是什么的API调用。
操作必须最终由主机审核。未经授权的用户必须不可能成功执行未经授权使用的主机呼叫,并且只有主机知道他是否是。客户端永远不是权威。