我尝试基于角色的授权,以便根据已登录的候选人是admin或user来控制对数据库的访问。
在创建Permissions.js文件时,出现以下错误:
作业的左侧必须是变量
Permissions.js中的代码如下:
/**Authorization Permissions**/
angular.module('fyiApp').factory('permissions', function($rootScope) {
var permissionList = [];
return {
setPermissions: function(permissions) {
permissionList = permissions;
$rootScope.$broadcast('permissionsChanged');
},
hasPermission: function (permission) {
permission = permission.trim();
return permissionList.some(item => {
if (typeof item.Name !== 'string') { // item.Name is only used because when I called setPermission, I had a Name property
return false;
}
return item.Name.trim() === permission;
});
}
};
});
我该如何解决?